Skip to content

Commit 225ca98

Browse files
committed
Add SLSA source provenance workflow and VSA integration
New source-provenance.yml workflow runs on push to main, creates a deterministic git archive, and attests it with SLSA build provenance. build.yml gains four steps after existing provenance attestations: generate source archive, verify source provenance (continue-on-error), generate SLSA VSA predicate, and attest binary artifacts with it. VSA steps are skipped gracefully when source attestation is absent (e.g. race on push, non-main commits). https://claude.ai/code/session_01TGzde6LDNw9q7aK9JE5jGf
1 parent 98352d4 commit 225ca98

2 files changed

Lines changed: 97 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,50 @@ jobs:
175175
--cert-identity "https://github.com/${{ github.repository }}/.github/workflows/build.yml@${{ github.ref }}" \
176176
--cert-oidc-issuer https://token.actions.githubusercontent.com
177177
done
178+
- name: Generate source archive for VSA
179+
shell: bash
180+
run: git archive HEAD --format=tar.gz -o source.tar.gz
181+
- name: Verify source provenance
182+
id: verify-source
183+
continue-on-error: true
184+
shell: bash
185+
env:
186+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187+
run: |
188+
gh attestation verify source.tar.gz \
189+
--repo "${{ github.repository }}" \
190+
--predicate-type https://slsa.dev/provenance/v1 \
191+
--cert-identity "https://github.com/${{ github.repository }}/.github/workflows/source-provenance.yml@refs/heads/main" \
192+
--cert-oidc-issuer https://token.actions.githubusercontent.com
193+
- name: Generate VSA predicate
194+
if: steps.verify-source.outcome == 'success'
195+
shell: bash
196+
run: |
197+
jq -n \
198+
--arg verifier "https://github.com/${{ github.repository }}/.github/workflows/build.yml@${{ github.ref }}" \
199+
--arg time "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
200+
--arg resource "git+https://github.com/${{ github.repository }}@${{ github.sha }}" \
201+
--arg policy "https://github.com/${{ github.repository }}/.github/workflows/source-provenance.yml@refs/heads/main" \
202+
'{
203+
verifier: { id: $verifier },
204+
timeVerified: $time,
205+
resourceUri: $resource,
206+
policy: { uri: $policy },
207+
inputAttestations: [],
208+
verificationResult: "PASSED",
209+
verifiedLevels: ["SLSA_BUILD_LEVEL_3"]
210+
}' > vsa-predicate.json
211+
- name: Attest build artifacts with VSA
212+
if: steps.verify-source.outcome == 'success'
213+
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
214+
with:
215+
subject-path: |
216+
build/dfetch-package/*.deb
217+
build/dfetch-package/*.rpm
218+
build/dfetch-package/*.pkg
219+
build/dfetch-package/*.msi
220+
predicate-type: 'https://slsa.dev/verification_summary/v1'
221+
predicate-path: vsa-predicate.json
178222
- name: Store the distribution packages
179223
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
180224
with:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Source Provenance
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
attest-source:
12+
name: Generate source provenance
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
attestations: write
17+
id-token: write
18+
19+
steps:
20+
- name: "Harden the runner (Block egress traffic: Only allow calls to allowed endpoints)"
21+
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
22+
with:
23+
egress-policy: block
24+
allowed-endpoints: >+
25+
github.com:443
26+
api.github.com:443
27+
fulcio.sigstore.dev:443
28+
rekor.sigstore.dev:443
29+
tuf-repo-cdn.sigstore.dev:443
30+
*.blob.core.windows.net:443
31+
32+
- name: Checkout repository
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
persist-credentials: false
36+
37+
- name: Generate source archive
38+
run: git archive HEAD --format=tar.gz -o source.tar.gz
39+
40+
- name: Attest source provenance
41+
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
42+
with:
43+
subject-path: source.tar.gz
44+
45+
- name: Verify source provenance
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
gh attestation verify source.tar.gz \
50+
--repo "${{ github.repository }}" \
51+
--predicate-type https://slsa.dev/provenance/v1 \
52+
--cert-identity "https://github.com/${{ github.repository }}/.github/workflows/source-provenance.yml@refs/heads/main" \
53+
--cert-oidc-issuer https://token.actions.githubusercontent.com

0 commit comments

Comments
 (0)