Skip to content

Commit 97be832

Browse files
hyperpolymathclaude
andcommitted
fix(security): remove eval from conformance runner
The conformance/run_conformance.sh script previously built a parser command as a string and invoked it via `eval "${PARSER}" "$f"`, which is a command-injection vector: a caller could pass $1 containing shell metacharacters and execute arbitrary commands as whoever runs the script. Fix: build PARSER_CMD as a Bash array. If the caller passes a parser command as $1, split it on whitespace into the array; otherwise use the default parser invocation as array literals directly. Invoke via `"${PARSER_CMD[@]}" "$f"` — no eval, no shell re-parsing. This is the same fix applied to my-lang/conformance/run_conformance.sh and is being rolled out across all language repos in the nextgen-languages monorepo that share the same original script pattern. Resolves one Critical panic-attack CommandInjection finding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 10cb351 commit 97be832

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

conformance/run_conformance.sh

100755100644
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010
set -euo pipefail
1111

1212
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13-
PARSER="${1:-deno run --allow-read "${SCRIPT_DIR}/../compiler/src/Parser.res.js" --parse-only}"
13+
# Build PARSER_CMD as an array so we never need `eval`. If the caller
14+
# passes a parser command as $1, split it on whitespace; otherwise use
15+
# the default command directly.
16+
if [[ -n "${1:-}" ]]; then
17+
# shellcheck disable=SC2206 # deliberate word-splitting of caller's string
18+
PARSER_CMD=(${1})
19+
else
20+
PARSER_CMD=(deno run --allow-read "${SCRIPT_DIR}/../compiler/src/Parser.res.js" --parse-only)
21+
fi
1422

1523
PASS=0
1624
FAIL=0
@@ -20,7 +28,7 @@ TOTAL=0
2028
for f in "${SCRIPT_DIR}"/valid/*.err; do
2129
TOTAL=$((TOTAL + 1))
2230
name="$(basename "$f")"
23-
if eval "${PARSER}" "$f" >/dev/null 2>&1; then
31+
if "${PARSER_CMD[@]}" "$f" >/dev/null 2>&1; then
2432
echo " PASS valid/${name}"
2533
PASS=$((PASS + 1))
2634
else
@@ -33,7 +41,7 @@ done
3341
for f in "${SCRIPT_DIR}"/invalid/*.err; do
3442
TOTAL=$((TOTAL + 1))
3543
name="$(basename "$f")"
36-
if eval "${PARSER}" "$f" >/dev/null 2>&1; then
44+
if "${PARSER_CMD[@]}" "$f" >/dev/null 2>&1; then
3745
echo " FAIL invalid/${name} (expected failure, got success)"
3846
FAIL=$((FAIL + 1))
3947
else

0 commit comments

Comments
 (0)