-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add SLSA generic generator workflow #1573
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
base: main
Are you sure you want to change the base?
Changes from all commits
900021b
afb6009
4d98e10
ea38f91
de34ba3
28c9ce2
324ac78
9d726f3
287e964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||||||||||||||||||||||||||||||
| # This workflow uses actions that are not certified by GitHub. | ||||||||||||||||||||||||||||||||||
| # They are provided by a third-party and are governed by | ||||||||||||||||||||||||||||||||||
| # separate terms of service, privacy policy, and support | ||||||||||||||||||||||||||||||||||
| # documentation. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # This workflow lets you generate SLSA provenance file for your project. | ||||||||||||||||||||||||||||||||||
| # The generation satisfies level 3 for the provenance requirements - see https://slsa.dev/spec/v0.1/requirements | ||||||||||||||||||||||||||||||||||
| # The project is an initiative of the OpenSSF (openssf.org) and is developed at | ||||||||||||||||||||||||||||||||||
| # https://github.com/slsa-framework/slsa-github-generator. | ||||||||||||||||||||||||||||||||||
| # The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier. | ||||||||||||||||||||||||||||||||||
| # For more information about SLSA and how it improves the supply-chain, visit slsa.dev. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| name: SLSA generic generator | ||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||
| release: | ||||||||||||||||||||||||||||||||||
| types: [created] | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||
| outputs: | ||||||||||||||||||||||||||||||||||
| digests: ${{ steps.hash.outputs.digests }} | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+24
|
||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # ======================================================== | ||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||
| # Step 1: Build your artifacts. | ||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||
| # ======================================================== | ||||||||||||||||||||||||||||||||||
| - name: Build artifacts | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| # These are some amazing artifacts. | ||||||||||||||||||||||||||||||||||
| echo "artifact1" > artifact1 | ||||||||||||||||||||||||||||||||||
| echo "artifact2" > artifact2 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
paulthanson082-glitch marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||
| - name: Upload build artifacts | ||||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||
| name: build-artifacts | ||||||||||||||||||||||||||||||||||
| path: artifact* | ||||||||||||||||||||||||||||||||||
| # ======================================================== | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+41
to
+44
|
||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||
| # Step 2: Add a step to generate the provenance subjects | ||||||||||||||||||||||||||||||||||
| # as shown below. Update the sha256 sum arguments | ||||||||||||||||||||||||||||||||||
| # to include all binaries that you generate | ||||||||||||||||||||||||||||||||||
| # provenance for. | ||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||
| # ======================================================== | ||||||||||||||||||||||||||||||||||
| - name: Generate subject for provenance | ||||||||||||||||||||||||||||||||||
| id: hash | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # List the artifacts the provenance will refer to. | ||||||||||||||||||||||||||||||||||
| files=$(compgen -G "artifact*" || true) | ||||||||||||||||||||||||||||||||||
| if [ -z "$files" ]; then | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| echo "Error: no artifacts found matching pattern 'artifact*'." >&2 | ||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| # Generate the subjects (base64 encoded). | ||||||||||||||||||||||||||||||||||
| echo "hashes=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}" | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| echo "hashes=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}" | |
| echo "digests=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}" |
Copilot
AI
Feb 5, 2026
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.
The variable files may contain newlines if multiple files match the pattern, which could cause issues with the unquoted variable expansion in the sha256sum command on line 59. If filenames contain spaces or special characters, this could lead to incorrect behavior or security issues.
Consider using a safer approach such as:
- Using an array to store filenames
- Quoting the variable properly
- Using find with -print0 and xargs -0 for more robust file handling
| files=$(compgen -G "artifact*" || true) | |
| if [ -z "$files" ]; then | |
| echo "Error: no artifacts found matching pattern 'artifact*'." >&2 | |
| exit 1 | |
| fi | |
| # Generate the subjects (base64 encoded). | |
| echo "hashes=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}" | |
| mapfile -t files < <(compgen -G "artifact*" || true) | |
| if [ "${#files[@]}" -eq 0 ]; then | |
| echo "Error: no artifacts found matching pattern 'artifact*'." >&2 | |
| exit 1 | |
| fi | |
| # Generate the subjects (base64 encoded). | |
| echo "hashes=$(sha256sum "${files[@]}" | base64 -w0)" >> "${GITHUB_OUTPUT}" |
Copilot
AI
Feb 5, 2026
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.
The workflow sets upload-assets: true which attempts to upload provenance to a release, but the workflow can be triggered by workflow_dispatch (manual trigger) when there is no release event. This will cause the provenance job to fail when manually triggered.
Consider either:
- Removing
workflow_dispatchfrom the triggers if assets should only be uploaded during releases - Making
upload-assetsconditional based on the trigger type - Setting
upload-assets: falseand handling asset uploads separately
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.
This workflow doesn’t set explicit
permissionsforGITHUB_TOKEN. Other workflows in this repo do (e.g.,.github/workflows/lint.yml:2-3,.github/workflows/docs.yml:15-18,.github/workflows/release.yml:16-18). Add minimal permissions (likelycontents: readforbuild, and only what’s needed forprovenance) to follow the repo’s pattern and reduce token scope.