From 7728c2cf14ab64892561902f8713e5ff8bda4608 Mon Sep 17 00:00:00 2001 From: Timothy Kassis Date: Wed, 30 Sep 2026 16:40:13 -0700 Subject: [PATCH] fix(ci): explicitly skip security scanning for restricted PRs Fixes #288. Keep fork and Dependabot runs away from secrets and comment writes; publish an explicit skip notice and put available reports in job summaries. --- .github/workflows/pr-skill-scan.yml | 32 ++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-skill-scan.yml b/.github/workflows/pr-skill-scan.yml index ef6c5a62..e3db8a5a 100644 --- a/.github/workflows/pr-skill-scan.yml +++ b/.github/workflows/pr-skill-scan.yml @@ -12,17 +12,39 @@ on: permissions: contents: read - pull-requests: write concurrency: group: pr-skill-scan-${{ github.event.pull_request.number }} cancel-in-progress: true jobs: + scan-unavailable: + name: Security scan skipped (restricted PR) + if: github.event.pull_request.head.repo.full_name != github.repository || github.actor == 'dependabot[bot]' + runs-on: ubuntu-latest + permissions: {} + steps: + - name: Explain why the security scan did not run + run: | + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ## Skill security scan skipped + + Fork and Dependabot pull requests do not receive the Actions secret used + by this scanner and have a read-only token. No security scan ran, and no + PR comment was attempted. This is not a passing security assessment. + + A maintainer can review the changes and run `scan_pr_skills.py` in a + trusted environment before merging. + EOF + scan: name: Scan changed skills + if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' runs-on: ubuntu-latest timeout-minutes: 60 + permissions: + contents: read + pull-requests: write steps: - name: Checkout PR @@ -73,8 +95,8 @@ jobs: if: steps.changed.outputs.skill_dirs != '' run: uv sync --python 3.13 - # Fork PRs do not receive SKILL_SCANNER_LLM_API_KEY. scan_pr_skills.py - # detects the missing key, writes an explanatory sticky comment, and exits 0. + # Same-repository runs can still lack a configured key. The wrapper writes + # an explicit skipped report, which is published in the summary and comment. - name: Run scanner on changed skills if: steps.changed.outputs.skill_dirs != '' id: scan @@ -97,6 +119,10 @@ jobs: No skill directories (with a `SKILL.md`) were changed in this PR — nothing to scan. EOF + - name: Publish scan report in the job summary + if: always() && hashFiles('pr_scan_comment.md') != '' + run: cat pr_scan_comment.md >> "$GITHUB_STEP_SUMMARY" + - name: Upload scan comment as artifact if: always() uses: actions/upload-artifact@v4