Skip to content

Commit 1237fc6

Browse files
Sandbox Process Creation
1 parent 855b9a7 commit 1237fc6

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

examples/other_languages.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from subprocess import PIPE, Popen
77

88
from sigopt import Connection
9+
from security import safe_command
910

1011

1112
class SubProcessEvaluator(object):
@@ -23,7 +24,7 @@ def evaluate_metric(self, assignments):
2324
arguments = [
2425
"--{}={}".format(param_name, assignment) for param_name, assignment in assignments.to_json().iteritems()
2526
]
26-
process = Popen(self.command.split() + arguments, stdout=PIPE, stderr=PIPE)
27+
process = safe_command.run(Popen, self.command.split() + arguments, stdout=PIPE, stderr=PIPE)
2728
(stdoutdata, stderrdata) = process.communicate()
2829
sys.stderr.write(stderrdata)
2930
return float(stdoutdata.strip())

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ pypng>=0.0.20
66
PyYAML>=5,<7
77
requests>=2.25.0,<3.0.0
88
urllib3>=1.26.5,<2.0.0
9+
security==1.3.1

sigopt/cli/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from sigopt.sigopt_logging import enable_print_logging, print_logger
1818

1919
from .arguments.load_yaml import ValidatedData
20+
from security import safe_command
2021

2122

2223
class StreamThread(threading.Thread):
@@ -80,8 +81,7 @@ def run_subprocess_command(config, run_context, cmd, env=None):
8081
env = get_subprocess_environment(config, run_context, env)
8182
proc_stdout, proc_stderr = subprocess.PIPE, subprocess.PIPE
8283
try:
83-
proc = subprocess.Popen(
84-
cmd,
84+
proc = safe_command.run(subprocess.Popen, cmd,
8585
env=env,
8686
stdout=proc_stdout,
8787
stderr=proc_stderr,

0 commit comments

Comments
 (0)