Skip to content

Commit 3dde0fd

Browse files
committed
Allow setting "--security-opt no-new-privileges"
1 parent 4f6780e commit 3dde0fd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

starter/runner.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"PYTHON_RUNNER_TMPFS_MOUNT_SIZE_IN_BYTES", "104857600"
5151
)
5252
DROPPED_CAPABILITIES = os.environ.get('PYTHON_RUNNER_DROPPED_CAPABILITIES', []).split(',')
53+
NO_NEW_PRIVILEGES = os.environ.get('PYTHON_RUNNER_NO_NEW_PRIVILEGES', 'false').lower() == "true"
5354
OTHER_OPTIONS = os.environ.get("PYTHON_RUNNER_OTHER_OPTIONS", "[]")
5455
try:
5556
OTHER_OPTIONS = ast.literal_eval(OTHER_OPTIONS)
@@ -311,6 +312,9 @@ def run_python(data):
311312
)
312313
if DROPPED_CAPABILITIES:
313314
command.extend(f'--cap-drop={capability}' for capability in DROPPED_CAPABILITIES)
315+
if NO_NEW_PRIVILEGES:
316+
# Prevent container from gaining additional privileges
317+
command.append('--security-opt no-new-privileges')
314318
# other options, these options are experimental, may cause failure to start script
315319
if OTHER_OPTIONS and isinstance(OTHER_OPTIONS, list):
316320
for option in OTHER_OPTIONS:

0 commit comments

Comments
 (0)