diff options
| author | Octavian Guzu <oct@anthropic.com> | 2026-04-28 11:41:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-28 11:41:07 +0100 |
| commit | 99832739a1b76c6ffa25c03f2c351bbd68f7cf45 (patch) | |
| tree | 1b7b329c87d1c7ca4365a2e4167a437994aeaba6 | |
| parent | c5837a2c23b6ae1d89d3ed8212db20984d41b6a1 (diff) | |
| parent | 068a59e000f2aa4f0dee0fc5bb4d196c6120a3e6 (diff) | |
Merge pull request #1621 from anthropics/fix/validate-frontmatter-shell-injection
Harden validate-frontmatter workflow
| -rw-r--r-- | .github/workflows/validate-frontmatter.yml | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/.github/workflows/validate-frontmatter.yml b/.github/workflows/validate-frontmatter.yml index 9de76f70..dc2ea6aa 100644 --- a/.github/workflows/validate-frontmatter.yml +++ b/.github/workflows/validate-frontmatter.yml @@ -9,6 +9,10 @@ on: jobs: validate: + # Fork PRs are auto-closed by close-external-prs.yml, so skip validation + # for them entirely. This also prevents untrusted filenames from forks + # from ever reaching the shell steps below. + if: github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -20,16 +24,19 @@ jobs: - name: Get changed frontmatter files id: changed + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} run: | # Use diff-filter=AMRC to exclude deleted files (D) - only Added, Modified, Renamed, Copied - FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only --diff-filter=AMRC | grep -E '(agents/.*\.md|skills/.*/SKILL\.md|commands/.*\.md)$' || true) + FILES=$(gh pr diff "$PR_NUMBER" --name-only --diff-filter=AMRC | grep -E '(agents/.*\.md|skills/.*/SKILL\.md|commands/.*\.md)$' || true) echo "files<<EOF" >> "$GITHUB_OUTPUT" echo "$FILES" >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" - env: - GH_TOKEN: ${{ github.token }} - name: Validate frontmatter if: steps.changed.outputs.files != '' + env: + FILES: ${{ steps.changed.outputs.files }} run: | - echo "${{ steps.changed.outputs.files }}" | xargs bun .github/scripts/validate-frontmatter.ts + printf '%s\n' "$FILES" | xargs bun .github/scripts/validate-frontmatter.ts |
