Dhairya-007 opened a new pull request, #31076:
URL: https://github.com/apache/camel/pull/31076

   # Rationale for this change
   
   Follow-up to #31071, same defect class in the main PR build. 
`pr-build-main.yml` expands `${{ github.event.number || inputs.pr_number }}` 
directly inside two `run:` blocks:
   
   ```yaml
   # "Fail if there are uncommitted changes"
   echo "${{ github.event.number || inputs.pr_number }}" > 
regen-patch-artifact/pr-number
   
   # "Save PR number and test comment for commenter workflow"
   prNumber="${{ github.event.number || inputs.pr_number }}"
   ```
   
   GitHub substitutes `${{ }}` textually before bash parses the script, so the 
value lands in the command as script rather than as data. `github.event.number` 
is an integer and harmless; `inputs.pr_number` is a free-text 
`workflow_dispatch` input (`type: string`, used as `gh workflow run "Build and 
test" -f pr_number=XXXX`), so it is the one that matters.
   
   As in #31071, this needs write access to exercise, so it is hardening rather 
than a hole open to the public. I am not claiming an exploit. It is cheap to 
close, `CLAUDE.md` asks contributors not to leave static-analysis findings 
lying around, and the file already does the right thing one step down — the 
second of the two steps has an `env:` block for `RUN_URL`, so this is the 
pattern the file itself already uses.
   
   ## What changed
   
   The first step gains an `env:` block; the second gets one more entry on the 
block it already has:
   
   ```yaml
         - name: Fail if there are uncommitted changes
           if: ${{ !inputs.skip_full_build }}
           shell: bash
           env:
             PR_NUMBER: ${{ github.event.number || inputs.pr_number }}
           run: |
             ...
             echo "$PR_NUMBER" > regen-patch-artifact/pr-number
   ```
   
   ```yaml
           env:
             RUN_URL: ${{ github.server_url }}/${{ github.repository 
}}/actions/runs/${{ github.run_id }}
             PR_NUMBER: ${{ github.event.number || inputs.pr_number }}
           run: |
             mkdir -p ci-comment-artifact
             prNumber="$PR_NUMBER"
   ```
   
   The `||` fallback keeps working: GitHub evaluates it when building the 
`env:` value, exactly as it did when building the script text, so a 
`pull_request` run still gets `github.event.number` and a dispatched run still 
gets the input.
   
   Five lines, one file. No change to triggers, jobs, matrices or artifact 
contents.
   
   ## Are these changes tested?
   
   ```console
   # zizmor, before
   6 findings (4 suppressed): 0 informational, 0 low, 0 medium, 2 high
      -> 2x error[template-injection], lines 165 and 222
   
   # zizmor, after
   No findings to report. Good job! (2 suppressed)
   
   # actionlint: 7 findings before, 7 after -- identical
   ```
   
   The 7 actionlint findings are pre-existing and untouched: three 
`maven_extra_args` expression notes and four shellcheck infos. Worth saying 
explicitly that I looked at the `maven_extra_args` ones and left them alone on 
purpose — they are written `${{ matrix.maven_extra_args || '' }}`, so the 
absence of the key from the matrix is clearly deliberate and actionlint is 
simply being pedantic there.
   
   I could not execute the workflow: it runs on `pull_request` and 
`workflow_dispatch` against the apache repository. The argument rests on 
`env:`-versus-`${{ }}` expansion semantics, which are well established, plus 
the static checks above.
   
   ## Are there any user-facing changes?
   
   No. CI only.
   
   ---
   
   _Claude Code on behalf of Dhairya-007_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] ci: pass the PR number t... Dhairya-007 (via GitHub) via commits

Reply via email to