ci(security): add Zizmor GitHub Actions workflow scanner - #55
Conversation
Reviewer's GuideIntroduces a least-privilege, pinned GitHub Actions workflow that runs Zizmor against repository workflows on relevant changes and weekly, then uploads SARIF results to GitHub Security & Quality via Code Scanning. Sequence diagram for the Zizmor workflow security scansequenceDiagram
participant Trigger as Workflow trigger
participant Actions as GitHub Actions
participant Checkout as actions/checkout
participant Zizmor as zizmor-action
participant CodeScanning as GitHub Code Scanning
Trigger->>Actions: Start zizmor workflow
Actions->>Checkout: Checkout repository
Checkout-->>Actions: Workflow files available
Actions->>Zizmor: Run zizmor security audit
Zizmor-->>Actions: Write results.sarif
Actions->>CodeScanning: upload-sarif(results.sarif)
CodeScanning-->>Actions: Publish findings to Security & Quality
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/zizmor.yml" line_range="42" />
<code_context>
+ - name: Run zizmor security audit
+ uses: woodruffw/zizmor-action@a87be7b233a0b8106f3634ea576ca22ebc29ffc1 # v1.4.1
+ with:
+ args: --format sarif .
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
</code_context>
<issue_to_address>
**issue (bug_risk):** When Zizmor finds a policy violation, the audit step exits nonzero and GitHub skips the subsequent `upload-sarif` step because it has the default `success()` condition, so the SARIF findings are not uploaded to Code Scanning.
**Triggers:** When the scanned workflows contain at least one Zizmor finding.
**Suggested fix:** Add `if: ${{ always() }}` to the SARIF upload step so the report is uploaded even when the audit step reports findings.
</issue_to_address>
### Comment 2
<location path=".github/workflows/zizmor.yml" line_range="46" />
<code_context>
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ security-events: write
+ steps:
+ - name: Check out repository
</code_context>
<issue_to_address>
**issue (bug_risk):** When this workflow runs for a pull request from a fork, GitHub downgrades the `GITHUB_TOKEN` to read-only despite `security-events: write`, so `upload-sarif` cannot write the Code Scanning result and the workflow fails with a resource-access error.
**Triggers:** When an external contributor opens a pull request that changes a workflow file.
**Suggested fix:** Skip SARIF uploading for fork pull requests, or use a separately trusted `pull_request_target` workflow that does not execute untrusted checkout contents.
```suggestion
- name: Upload SARIF report to Code Scanning
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false
```
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and the workflow adds a pinned third-party action that executes with repository-read and security-events-write permissions and uploads scan findings to GitHub Code Scanning. A faulty scanner or action could produce incorrect or stale security results, but reverting stops future runs and the persisted findings can be cleared or regenerated.
Blocking findings: .github/workflows/zizmor.yml:42, .github/workflows/zizmor.yml:46
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
|
@sourcery-ai review |
Integrate Zizmor security scanner for static analysis of GitHub Actions workflows with SARIF reporting to GitHub Security & Quality dashboard.
Summary by Sourcery
Add automated security scanning for GitHub Actions workflows with Zizmor and GitHub Code Scanning integration.
Enhancements:
CI: