Potential fix for code scanning alert no. 40: Checkout of untrusted code in a non-privileged context
Potential fix for https://github.com/petry-projects/.github-private/security/code-scanning/40
Best fix: validate and constrain inputs.agent_ref before checkout, and fail closed on unsafe values. This keeps existing functionality (still allows intended pinned channels/branches/tags) while preventing PR refs/SHAs/paths that could be attacker-controlled in untrusted contexts.
In .github/workflows/dev-lead-reusable.yml, add a new step immediately before “Checkout dev-lead scripts” that:
- Normalizes
inputs.agent_refwith fallback tomain. - Rejects dangerous patterns such as
refs/pull/*, raw 40-hex SHAs, traversal characters, whitespace, or other non-safe characters. - Exports a validated ref (for example
SAFE_AGENT_REF) into$GITHUB_ENV.
Then change the checkout step’s ref from ${{ inputs.agent_ref }} to ${{ env.SAFE_AGENT_REF }}.
No new dependencies are needed; shell validation is sufficient.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Problem
See the linked issue.
Risk
Medium — changes GitHub Actions workflow behavior, which is exercised only post-merge; verify via the affected workflow runs.
Test plan
No test files were added or updated. Verification: bash scripts/dev-lead-lint.sh (shellcheck --severity=warning) ran pre-commit; the existing CI (bats + lint) guards the change.
Rollback
Revert this PR. No non-revertible side effects (no tags, migrations, or external state).
Monitoring
Watch the affected workflow run(s) in the Actions tab and this PR's Lint check for regressions.