@@ -15,6 +15,14 @@ This script builds and runs benchmarks from compute-benchmarks."
1515 exit 1
1616}
1717
18+ # Ensures test cases read from enabled_tests.conf contains no malicious content
19+ _validate_testname () {
20+ if [ -n " $( printf " %s" " $1 " | sed " s/[a-zA-Z_]*//g" ) " ]; then
21+ echo " Illegal characters in $TEST_CONFIG . Permitted characters: a-zA-Z_"
22+ exit 1
23+ fi
24+ }
25+
1826clone_perf_res () {
1927 echo " ### Cloning llvm-ci-perf-results ($SANITIZED_PERF_RES_GIT_REPO :$SANITIZED_PERF_RES_GIT_BRANCH ) ###"
2028 git clone -b " $SANITIZED_PERF_RES_GIT_BRANCH " " https://github.com/$SANITIZED_PERF_RES_GIT_REPO " ./llvm-ci-perf-results
@@ -43,11 +51,7 @@ build_compute_bench() {
4351 # Skip lines starting with '#'
4452 [ " ${case## \# * } " ] || continue
4553
46- if [ -n " $( printf " %s" " $case " | sed " s/[a-zA-Z_]*//g" ) " ]; then
47- echo " Illegal characters in $TESTS_CONFIG ."
48- exit 1
49- fi
50- # TODO Sanitize this
54+ _validate_testname " $case "
5155 make " -j$SANITIZED_COMPUTE_BENCH_COMPILE_JOBS " " $case "
5256 done < " $TESTS_CONFIG "
5357 fi
@@ -117,11 +121,7 @@ process_benchmarks() {
117121 # Loop through each line of enabled_tests.conf, but ignore lines in the
118122 # test config starting with #'s:
119123 grep " ^[^#]" " $TESTS_CONFIG " | while read -r testcase; do
120- # Make sure testcase is clean:
121- if [ -n " $( printf " %s" " $testcase " | sed " s/[a-zA-Z_]*//g" ) " ]; then
122- echo " Illegal characters in $TESTS_CONFIG ."
123- exit 1
124- fi
124+ _validate_testname " $testcase "
125125 echo " # Running $testcase ..."
126126
127127 # The benchmark results git repo and this script's output both share
0 commit comments