File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 4949TMPFS_MOUNT_SIZE_IN_BYTES = os .environ .get (
5050 "PYTHON_RUNNER_TMPFS_MOUNT_SIZE_IN_BYTES" , "104857600"
5151)
52+ DROPPED_CAPABILITIES = [
53+ cap
54+ for cap in os .environ .get ("PYTHON_RUNNER_DROPPED_CAPABILITIES" , "" ).split ("," )
55+ if cap .strip ()
56+ ]
57+ NO_NEW_PRIVILEGES = (
58+ os .environ .get ("PYTHON_RUNNER_NO_NEW_PRIVILEGES" , "false" ).lower () == "true"
59+ )
5260OTHER_OPTIONS = os .environ .get ("PYTHON_RUNNER_OTHER_OPTIONS" , "[]" )
5361try :
5462 OTHER_OPTIONS = ast .literal_eval (OTHER_OPTIONS )
@@ -308,6 +316,13 @@ def run_python(data):
308316 command .extend (
309317 ["--mount" , f"type=tmpfs,dst=/tmp,tmpfs-size={ TMPFS_MOUNT_SIZE_IN_BYTES } " ]
310318 )
319+ if DROPPED_CAPABILITIES :
320+ command .extend (
321+ f"--cap-drop={ capability } " for capability in DROPPED_CAPABILITIES
322+ )
323+ if NO_NEW_PRIVILEGES :
324+ # Prevent container from gaining additional privileges
325+ command .extend (["--security-opt" , "no-new-privileges" ])
311326 # other options, these options are experimental, may cause failure to start script
312327 if OTHER_OPTIONS and isinstance (OTHER_OPTIONS , list ):
313328 for option in OTHER_OPTIONS :
You can’t perform that action at this time.
0 commit comments