-
Notifications
You must be signed in to change notification settings - Fork 46
Add poutine supply-chain scan for GitHub Actions workflows #1156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
reitblatt
wants to merge
4
commits into
roostorg:main
Choose a base branch
from
reitblatt:ci/poutine-pipeline-scan
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
39bb3cf
Add poutine supply-chain scan for GitHub Actions workflows
reitblatt 4406cec
Use the official poutine-action instead of a hand-rolled scan script
reitblatt 1a843e7
Apply review feedback from the zizmor rollout
reitblatt fd75951
Merge branch 'main' into ci/poutine-pipeline-scan
cassidyjames File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| name: Pipeline supply-chain analysis | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| paths: | ||
| - '.github/workflows/**' | ||
| - '.github/actions/**' | ||
| pull_request: | ||
| branches: ['**'] | ||
| paths: | ||
| - '.github/workflows/**' | ||
| - '.github/actions/**' | ||
| schedule: | ||
| # Weekly drift check: new poutine rules / advisories can flag workflows | ||
| # that were clean when they were last touched. | ||
| - cron: '17 6 * * 1' | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: poutine-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| poutine: | ||
| name: Run poutine | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| security-events: write # to upload SARIF results to code scanning | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| # Pinned to main@badd750a rather than the v1.1.4 tag: that tag still | ||
| # builds FROM poutine 1.1.4, while this commit builds FROM | ||
| # poutine:1.1.6@sha256:722a8e09..., so both the action and the scanner | ||
| # binary are pinned. Bump deliberately when upstream tags the 1.1.6 base. | ||
| - name: poutine - GitHub Actions SAST (human-readable) | ||
| uses: boostsecurityio/poutine-action@badd750a259150be3b8b00823ad60849d539b96d # main @ poutine 1.1.6 | ||
| env: | ||
| POUTINE_DISABLE_VERSION_CHECK: '1' | ||
| with: | ||
| format: pretty | ||
| output: poutine.txt | ||
|
|
||
| - name: poutine - GitHub Actions SAST (SARIF) | ||
| uses: boostsecurityio/poutine-action@badd750a259150be3b8b00823ad60849d539b96d # main @ poutine 1.1.6 | ||
| env: | ||
| POUTINE_DISABLE_VERSION_CHECK: '1' | ||
| with: | ||
| format: sarif | ||
| output: poutine.sarif | ||
|
|
||
| - name: Annotate pull request with findings | ||
| # PRs from forks cannot upload SARIF to code scanning, so surface | ||
| # findings as inline annotations instead. | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| run: | | ||
| jq -r ' | ||
| .runs[0].results[]? | ||
| | (.level // "warning") as $level | ||
| | (if $level == "error" then "error" | ||
| elif $level == "note" then "notice" | ||
| else "warning" end) as $kind | ||
| | .locations[0].physicalLocation as $loc | ||
| | "::\($kind) file=\($loc.artifactLocation.uri),line=\($loc.region.startLine // 1),title=poutine: \(.ruleId)::" | ||
| + (.message.text | gsub("\\s+"; " ") | .[0:400]) | ||
| ' poutine.sarif | ||
|
|
||
| # The action always exits 0, so gate here. Notes (e.g. actions from | ||
| # unverified creators) are reported but do not fail CI; warnings and | ||
| # errors do. | ||
| - name: Report and gate on findings | ||
| run: | | ||
| { | ||
| echo '## poutine' | ||
| echo '```' | ||
| cat poutine.txt | ||
| echo '```' | ||
| } >>"$GITHUB_STEP_SUMMARY" | ||
|
|
||
| blocking="$(jq ' | ||
| [.runs[0].results[]? | select((.level // "warning") | test("^(warning|error)$"))] | ||
| | length | ||
| ' poutine.sarif)" | ||
|
|
||
| if [ "$blocking" -gt 0 ]; then | ||
| echo "::error title=poutine::${blocking} finding(s) at warning level or above" | ||
| exit 1 | ||
| fi | ||
| echo "poutine: no findings at warning level or above" | ||
|
|
||
| - name: Upload SARIF to code scanning | ||
| if: ${{ always() && github.event_name != 'pull_request' }} | ||
| uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0 | ||
| with: | ||
| sarif_file: poutine.sarif | ||
| category: poutine | ||
|
|
||
| - name: Upload poutine reports | ||
| if: ${{ always() }} | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| with: | ||
| name: poutine-reports | ||
| path: | | ||
| poutine.sarif | ||
| poutine.txt | ||
| if-no-files-found: warn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add this to our changelog if it's not user-facing? cc @cassidyjames