Skip to content

Harden action.yml: env-var quoting, set -euo pipefail, fix line-count bug - #11

Merged
scruplelesswizard merged 2 commits into
mainfrom
harden/action-shell-quoting-and-error-handling
Jul 31, 2026
Merged

Harden action.yml: env-var quoting, set -euo pipefail, fix line-count bug#11
scruplelesswizard merged 2 commits into
mainfrom
harden/action-shell-quoting-and-error-handling

Conversation

@scruplelesswizard

Copy link
Copy Markdown
Owner

Follow-up from the maintainer audit in REVIEW.adoc. Bundles the remaining shell-hardening fixes for action.yml into one PR since they're all in the same file and the same run steps:

  • Script-injection surface: every ${{ inputs.* }} reference is now routed through env: instead of being interpolated directly into run:. Previously a caller-controlled input value became literal bash source at template-substitution time (before bash ever parsed the script) — GitHub's documented script-injection anti-pattern.
  • Structural fix for the quoting bug class: split_tests arguments are now built as bash arrays (SPLIT_BY=(...), EXCLUDE_GLOB=(...)) instead of unquoted strings. This is the same category of bug that broke exclude-glob (fixed in Exclude Glob doesn't exclude #9) — arrays make it structurally impossible to lose quoting on re-expansion, for every argument, not just the one that happened to get reported.
  • Silent-failure fix: set -euo pipefail added to both composite steps (plus curl -f), so a failed download or a failed split_tests run now fails the job loudly instead of possibly emitting an empty test-suite output that a downstream job would silently treat as "0 tests, all green."
  • line-count: false bug: the old check ([ -n "${{ inputs.line-count }}" ]) was true for the literal string "false", so explicitly disabling line-count mode didn't work. Now compares against the literal string "true".
  • Multiline-safe output: $GITHUB_OUTPUT now uses the heredoc form instead of single-line name=value, which would silently break if the test-suite list ever contained a newline.

Verified the argument-building logic locally (bash array expansion keeps glob patterns as single, correctly-quoted arguments; line-count: false takes the default path instead of the line-count path) before opening this.

… bug

- Route all inputs through env: instead of interpolating ${{ }} directly
  into run:, closing the GitHub Actions script-injection anti-pattern.
- Build split_tests arguments as bash arrays instead of unquoted strings,
  so quoting can't be lost on re-expansion (same class of bug fixed for
  exclude-glob in #9, now fixed structurally for every argument).
- Add set -euo pipefail to both composite steps so a failed download or
  failed split_tests run fails the job loudly instead of silently
  emitting an empty test-suite output.
- Fix line-count: false being treated as truthy (-n check on the string
  "false" is true); now compared against the literal string "true".
- Switch $GITHUB_OUTPUT to the multiline-safe heredoc form.
@scruplelesswizard
scruplelesswizard merged commit 7091966 into main Jul 31, 2026
5 checks passed
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