Skip to content

fix: test.sh's eval invocation dropped all but one coverage flag, and was a real injection risk - #97

Merged
frostebite merged 1 commit into
mainfrom
fix/test-sh-eval-array-bug
Aug 18, 2026
Merged

frostebite merged 1 commit into
mainfrom
fix/test-sh-eval-array-bug

Conversation

@frostebite

Copy link
Copy Markdown
Member

Found via a real CI failure on unity-test-runner's thin-wrapper PR (#310): after fixing the version-pin gap (#96), every single Docker test run still produced no results file at all.

Two bugs, both introduced in #95:

  1. COVERAGE_FLAGS was converted to a bash array (to avoid the eval below), but the unity-editor invocation still referenced it as plain $COVERAGE_FLAGS instead of "${COVERAGE_FLAGS[@]}" — unquoted, unsubscripted array expansion in bash only yields element [0]. Every run silently dropped -enableCodeCoverage/-coverageOptions and the coverageResultsPath value, leaving a bare -coverageResultsPath flag that then swallowed the next token (customParameters' first word) as its argument — corrupting the whole Unity command line.
  2. The invocation used eval to get CUSTOM_PARAMETERS to word-split into separate argv entries. CUSTOM_PARAMETERS is user-controlled (the action's own customParameters input) — eval would interpret any shell metacharacters in it (;, $(), backticks) as real shell syntax, a real command-injection surface.

Fix

Converted the whole invocation to a plain bash array (runTests, COVERAGE_FLAGS) with proper "${array[@]}" expansion. CUSTOM_PARAMETERS is still deliberately left unquoted for its intended word-splitting into separate args, but with eval gone entirely, that splitting can no longer be abused as shell syntax.

Testing

  • bash -n syntax check passes.
  • Full bun test ./src: 156 pass, 0 fail (this file isn't bundled into dist/index.js — it's a static asset mounted into the container at runtime, so nothing else needed rebuilding).
  • Will re-verify against a real Docker test run once this + a new release land (this exact script is what unity-test-runner's failing CI run was exercising).

🤖 Generated with Claude Code

… was a real injection risk

Found via a real CI failure on unity-test-runner's thin-wrapper PR:
every single Docker test run produced no results file at all.

Two bugs, both introduced in #95:

1. COVERAGE_FLAGS was converted to a bash array (to avoid the eval
   below), but the unity-editor invocation still referenced it as
   plain $COVERAGE_FLAGS instead of "${COVERAGE_FLAGS[@]}" - unquoted,
   unsubscripted array expansion in bash only yields element [0]. Every
   run silently dropped -enableCodeCoverage/-coverageOptions and the
   coverageResultsPath *value*, leaving a bare -coverageResultsPath flag
   that then swallowed the next token (customParameters' first word) as
   its argument - corrupting the whole Unity command line.

2. The invocation used `eval` to get CUSTOM_PARAMETERS to word-split
   into separate argv entries. CUSTOM_PARAMETERS is user-controlled
   (the action's own customParameters input) - eval would interpret
   any shell metacharacters in it (;, $(), backticks) as real shell
   syntax, a real command-injection surface.

Fixed by converting the whole invocation to a plain bash array
(runTests, COVERAGE_FLAGS) with proper "${array[@]}" expansion.
CUSTOM_PARAMETERS is still deliberately left unquoted for its intended
word-splitting into separate args, but with eval gone entirely, that
splitting can no longer be abused as shell syntax.

Verified: bash -n syntax check passes, full bun test suite still 156
pass/0 fail (this file isn't bundled into dist/index.js - it's a
static asset mounted into the container at runtime, so nothing else
needed rebuilding).
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c76612c-0a7a-4a8d-8088-0f63cb715b98


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@frostebite
frostebite merged commit 131431d into main Aug 18, 2026
15 checks passed
@frostebite
frostebite deleted the fix/test-sh-eval-array-bug branch August 18, 2026 20:12
frostebite added a commit that referenced this pull request Aug 18, 2026
Docker test runs on unity-test-runner's thin-wrapper PR fail near-
instantly with zero visible stdout - only two 'cat: no such file'
stderr lines from the very end of test.sh's loop body, meaning the
script reaches its last lines but nothing from mkdir/echo/unity-editor
earlier in the script is visible at all, and the whole thing completes
in well under a second (confirmed via job log timestamps) - too fast
for Unity to have actually launched.

Ruled out so far: the version-pin gap (#96, fixed), the eval/array bug
in the coverage flags (#97, fixed) - this is a third, still-unidentified
issue. set -x traces every command to stderr, which (unlike stdout) is
rendering promptly in the CI log, to find the actual failure point in
the next run. Temporary - will be removed once root-caused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant