1
1
# Generation of SLSA3+ provenance for arbitrary projects
2
2
3
- This document explains how to use the builder for projects for which there is no language-specific builder available.
3
+ This document explains how to generate SLSA provenance for projects for which
4
+ there is no language or ecosystem specific builder available.
5
+
6
+ This can be done by adding an additional step to your existing Github Actions
7
+ workflow to call a [ reusable
8
+ workflow] ( https://docs.github.com/en/actions/using-workflows/reusing-workflows )
9
+ to generate generic SLSA provenance. We'll call this workflow the "generic
10
+ workflow" from now on.
11
+
12
+ The generic workflow differs from ecosystem specific builders (like the [ Go
13
+ builder] ( ../go ) ) which build the artifacts as well as generate provenance. This
14
+ project simply generates provenance as a separate step in an existing workflow.
4
15
5
16
---
6
17
7
18
- [ Project Status] ( #project-status )
19
+ - [ Benefits of Provenance] ( #benefits-of-provenance )
8
20
- [ Generating Provenance] ( #generating-provenance )
9
21
- [ Getting Started] ( #getting-started )
10
22
- [ Workflow Inputs] ( #workflow-inputs )
@@ -19,9 +31,20 @@ This document explains how to use the builder for projects for which there is no
19
31
This project is currently under active development. The API could change while
20
32
approaching an initial release.
21
33
34
+ ## Benefits of Provenance
35
+
36
+ Using the generic workflow will generate a non-forgeable attestation to the
37
+ artifacts' digests using the identity of the GitHub workflow. This can be used
38
+ to create a positive attestation to a software artifact coming from your
39
+ repository.
40
+
41
+ That means that once your users verify the artifacts they have downloaded they
42
+ can be sure that the artifacts were created by your repository's workflow and
43
+ haven't been tampered with.
44
+
22
45
## Generating Provenance
23
46
24
- ` slsa-github-generator ` uses a Github Actions reusable workflow to generate the
47
+ The generic workflow uses a Github Actions reusable workflow to generate the
25
48
provenance.
26
49
27
50
### Getting Started
@@ -41,38 +64,97 @@ output:
41
64
$ sha256sum artifact1 artifact2 ... | base64 -w0
42
65
```
43
66
44
- After you have encoded your digest, add a new job to call the
45
- ` slsa-github-generator ` reusable workflow. Here's an example of what it might
46
- look like all together.
67
+ After you have encoded your digest, add a new job to call the reusable workflow.
68
+
69
+ ``` yaml
70
+ provenance :
71
+ permissions :
72
+ actions : read # Needed for detection of GitHub Actions environment.
73
+ id-token : write # Needed for provenance signing and ID
74
+ contents : read # Needed for API access
75
+ uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected]
76
+ with :
77
+ base64-subjects : " ${{ needs.build.outputs.digest }}"
78
+ ` ` `
79
+
80
+ Here's an example of what it might look like all together.
47
81
48
82
` ` ` yaml
49
83
jobs :
84
+ # This step builds our artifacts, uploads them to the workflow run, and
85
+ # outputs their digest.
50
86
build :
51
87
outputs :
52
88
digest : ${{ steps.hash.outputs.digest }}
53
89
runs-on : ubuntu-latest
54
90
steps :
55
91
- name : " build artifacts"
56
92
run : |
57
- # Build build artifacts here.
93
+ # These are some amazing artifacts.
94
+ echo "foo" > artifact1
95
+ echo "bar" > artifact2
58
96
- name : " generate hash"
59
97
shell : bash
60
98
id : hash
61
99
run : |
62
- set -euo pipefail
63
100
# sha256sum generates sha256 hash for all artifacts.
64
101
# base64 -w0 encodes to base64 and outputs on a single line.
65
102
# sha256sum artifact1 artifact2 ... | base64 -w0
66
103
echo "::set-output name=digest::$(sha256sum artifact1 artifact2 | base64 -w0)"
104
+ - name : Upload artifact1
105
+ uses : actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
106
+ with :
107
+ name : artifact1
108
+ path : artifact1
109
+ if-no-files-found : error
110
+ retention-days : 5
111
+ - name : Upload artifact2
112
+ uses : actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
113
+ with :
114
+ name : artifact2
115
+ path : artifact2
116
+ if-no-files-found : error
117
+ retention-days : 5
118
+
119
+ # This step calls the generic workflow to generate provenance.
67
120
provenance :
68
121
needs : [build]
69
122
permissions :
70
123
actions : read
71
124
id-token : write
72
125
contents : read
73
- uses : slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@main
126
+ if : startsWith(github.ref, 'refs/tags/')
127
+ uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected]
74
128
with :
75
129
base64-subjects : " ${{ needs.build.outputs.digest }}"
130
+
131
+ # This step creates a GitHub release with our artifacts and provenance.
132
+ release :
133
+ needs : [build, provenance]
134
+ runs-on : ubuntu-latest
135
+ if : startsWith(github.ref, 'refs/tags/')
136
+ steps :
137
+ - name : Download artifact1
138
+ uses : actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2.1.0
139
+ with :
140
+ name : artifact1
141
+ - name : Download artifact2
142
+ uses : actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2.1.0
143
+ with :
144
+ name : artifact2
145
+ - name : Download provenance
146
+ uses : actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2.1.0
147
+ with :
148
+ # The provenance step returns an output with the artifact name of
149
+ # our provenance.
150
+ name : ${{needs.provenance.outputs.attestation-name}}
151
+ - name : Create release
152
+ uses : softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
153
+ with :
154
+ files : |
155
+ artifact1
156
+ artifact2
157
+ ${{needs.provenance.outputs.attestation-name}}
76
158
` ` `
77
159
78
160
### Workflow Inputs
0 commit comments