Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
atlas-physics
pmg
MC Job Options
Commits
11cfbe6b
Commit
11cfbe6b
authored
May 12, 2021
by
Spyros Argyropoulos
Committed by
Christian Gutschow
May 12, 2021
Browse files
Skip execution of lines containing subprocess calls
parent
da4f1801
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/jo_utils.py
View file @
11cfbe6b
...
...
@@ -39,8 +39,9 @@ def _read_param_from_jo(jo, names, ignore_case=False):
# See https://gitlab.cern.ch/atlas-physics/pmg/mcjoboptions/-/issues/98
def
_read_param_from_jo_withDict
(
jo
,
type
,
param
):
locals
=
{
type
:
argparse
.
Namespace
()}
skipLines
=
[
"os.system"
,
"subprocess.call"
,
"subprocess.Popen"
]
# skip lines containing these calls
for
line
in
jo
.
splitlines
():
if
"os.system"
in
l
ine
:
continue
# for security
if
any
(
x
in
line
for
x
in
skipL
ine
s
)
:
continue
try
:
exec
(
line
,
{},
locals
)
except
:
...
...
@@ -55,8 +56,11 @@ def _env_set(jo, param):
os
.
environ
.
clear
()
# dictionary to store environment variables
locals
=
dict
()
# skip lines containing these calls
skipLines
=
[
"os.system"
,
"subprocess.call"
,
"subprocess.Popen"
]
# Execute jO
for
line
in
jo
.
splitlines
():
if
any
(
x
in
line
for
x
in
skipLines
):
continue
try
:
exec
(
line
.
strip
(),
globals
(),
locals
)
except
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment