Skip to content

Commit 5aeb593

Browse files
committed
Fix potential security issue in benchmark script
Close #294
1 parent 62c8d9f commit 5aeb593

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/bench-aggregator.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,30 @@
33
import json
44
import subprocess
55

6-
def run_benchmark(cmd):
7-
subprocess.run(cmd, shell=True, check=True)
6+
def run_benchmark(b):
7+
interp = None
8+
if "sh" in b:
9+
interp = "bash"
10+
elif "py" in b:
11+
interp = "python3"
12+
13+
subprocess.run(args=[interp, b], shell=False, check=True)
814

915
def load_benchmark(file):
1016
f = open(file, "r")
1117
return json.load(f)
1218

1319
# run benchmarks
1420
benchmarks = [
15-
"bash tests/dhrystone.sh",
16-
"python3 tests/coremark.py"
21+
"tests/dhrystone.sh",
22+
"tests/coremark.py"
1723
]
1824
for b in benchmarks:
1925
run_benchmark(b)
2026

2127
# combine benchmarks output data
2228
benchmarks_output = [
23-
"dhrystone_output.json",
29+
"dhrystone_output.json",
2430
"coremark_output.json"
2531
]
2632
benchmark_data = [load_benchmark(bo) for bo in benchmarks_output]

0 commit comments

Comments
 (0)