Skip to content

Pass inputs and outputs via env in test-arguments-action - #41592

Open
derrickaw wants to merge 2 commits into
masterfrom
codescan/gha-test-arguments-action-hardening
Open

derrickaw wants to merge 2 commits into
masterfrom
codescan/gha-test-arguments-action-hardening

Conversation

@derrickaw

@derrickaw derrickaw commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:

  • The PR remediates confirmed, live Code Scanning finding(s) (CodeQL / zizmor) on master without altering intended public API or workflow semantics
  • The fix is minimal, idiomatic, and avoids masking underlying defects (false positives and noisy rules are dismissed or scoped via config rather than code churn)
  • Relevant unit tests, linters, Gemini review feedback, and live workflow_dispatch runs (for workflow/action changes) have been verified

Initiative Progress (as of 2026-11-24 20:27 UTC): 8 PRs merged so far, with ~40 more PRs needed to be merged to close out all actionable Code Scanning findings (with #41637 disabling Note-level zizmor/self-repository warnings).

Code Scanning Remediation Context (End Goal, Scope & Impact)

If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)

Summary

Resolves all 12 open zizmor Code Scanning findings (High / error, alerts #175–#186: zizmor/template-injection and zizmor/github-env) in .github/actions/test-arguments-action/action.yml:

  • Pass composite action inputs.*, steps.*.outputs.*, and github.job values through step-level env: blocks instead of interpolating ${{ ... }} expressions directly inside bash run: scripts.
  • Preserve backward compatibility for caller workflows that pass literal $(date '+%m%d%H%M%S' --utc) timestamps or double-quote backslash escapes (\", \\\") via inputs.arguments without executing arbitrary shell command substitutions.
  • Validate JOB_ID, strip CR/LF characters (tr '\n\r' ' '), and write <job>_test_arguments_<index> entries cleanly to $GITHUB_ENV.

Verification

  • zizmor --persona=pedantic .github/actions/test-arguments-action/action.yml (0 findings, down from 16)
  • bash -n and byte-for-byte expansion verification across $(date '+%m%d%H%M%S' --utc), \", and \\\" caller patterns
  • ./gradlew :beam-test-gha:preCommit
  • Sample workflow_dispatch run of beam_Java_LoadTests_Combine_Smoke.yml against codescan/gha-test-arguments-action-hardening: https://github.com/apache/beam/actions/runs/45230834434 (succeeded across all 3 Dataflow Combine jobs)

@derrickaw

Copy link
Copy Markdown
Collaborator Author

/gemini review

@github-actions github-actions Bot added the size/s S: 10-49 lines changed label Nov 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This PR hardens .github/actions/test-arguments-action/action.yml against template injection by moving ${{ inputs.* }}, ${{ steps.* }}, and ${{ github.job }} interpolations into step env variables and validating JOB_ID. However, moving inputs.arguments from inline double-quoted shell interpolation to an environment variable stops bash from evaluating command substitutions like $(date '+%m%d%H%M%S' --utc) that several existing performance and load test workflows still pass via with: arguments:.

🔍 General Feedback

  • Passing action inputs via env: and validating JOB_ID before writing to $GITHUB_ENV are solid security improvements.
  • Caller workflows that still embed $(date '+%m%d%H%M%S' --utc) inside inputs.arguments (and subsequently pass the generated <job>_test_arguments_<index> env var inside single quotes to gradle-command-self-hosted-action) will now receive literal unexpanded $(date ...) tokens split across whitespace unless those workflows are updated.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This PR hardens .github/actions/test-arguments-action/action.yml against template injection and $GITHUB_ENV injection by routing composite action inputs, step outputs, and github.job through step-level env: blocks.

🔍 General Feedback

  • Passing inputs.arguments via INPUT_ARGUMENTS instead of direct ${{ inputs.arguments }} interpolation inside run: prevents bash command substitution (such as $(date '+%m%d%H%M%S' --utc)) from being evaluated, which will break callers that still pass $(date ...) in with: arguments:.
  • Overall, the environment variable bindings, JOB_ID validation, and newline sanitization cleanly address the zizmor findings.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This PR effectively resolves the zizmor template-injection and GITHUB_ENV security findings in .github/actions/test-arguments-action/action.yml by passing composite action inputs, step outputs, and github.job via environment variables rather than inline shell interpolation. It also preserves full backward compatibility for existing caller workflows that rely on literal $(date '+%m%d%H%M%S' --utc) timestamps and backslash-escaped quotes (\" and \\\") in inputs.arguments.

🔍 General Feedback

  • All 62 caller workflows across Java, Python, and Go load/performance suites are properly accounted for, including the distinction between inputs.arguments unescaping and CONFIG file preservation.
  • Validating JOB_ID and stripping CR/LF characters before writing to $GITHUB_ENV cleanly mitigates environment variable injection risks.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@derrickaw derrickaw added the ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review label Nov 23, 2026
@derrickaw derrickaw removed the ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review label Nov 25, 2026
@derrickaw
derrickaw marked this pull request as ready for review November 25, 2026 13:31
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @Abacn added as fallback since no labels match configuration
Backup reviewer: chamikaramj (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant