Skip to content

Commit e20f3cc

Browse files
feat: Verify all artifacts passed in cmdline (#419)
* Remove limit of number of artifacts to verify Signed-off-by: Mihai Maruseac <[email protected]> * Update short description Mention that we support multiple artifacts as long as they come from the same provenance. Signed-off-by: Mihai Maruseac <[email protected]> * Verify all artifacts passed in cmdline Signed-off-by: Mihai Maruseac <[email protected]> * Remove header of verify step output Signed-off-by: Mihai Maruseac <[email protected]> * Format the `cobra.Command.Use` argument Signed-off-by: Mihai Maruseac <[email protected]> * Don't return a slice of builderIDs. Since all images should come from the same provenance file, there's an invariant that we will always get exactly one builderID. So, no need to return a slice of them. Just to preempt the case when the invariant would be broken, add a specific check. Signed-off-by: Mihai Maruseac <[email protected]> * Change existing tests to support multiple artifacts. No new tests added, just changing table test data type. Signed-off-by: Mihai Maruseac <[email protected]> * [nfc] Format test file Signed-off-by: Mihai Maruseac <[email protected]> * Change test to allow passing multiple artifacts. For now, just allow passing the entire array of artifacts to command line / arguments. The functionality should still be the same. Signed-off-by: Mihai Maruseac <[email protected]> * Fix typo Signed-off-by: Mihai Maruseac <[email protected]> * Fix path to test artifacts Signed-off-by: Mihai Maruseac <[email protected]> * Allow different provenance path Signed-off-by: Mihai Maruseac <[email protected]> * Try 2 artifacts from existing testdata Signed-off-by: Mihai Maruseac <[email protected]> * Add more tests for multiple artifacts Signed-off-by: Mihai Maruseac <[email protected]> * Add failing test Signed-off-by: Mihai Maruseac <[email protected]> * Fix artifact and error Signed-off-by: Mihai Maruseac <[email protected]> * Add final test: no artifact match Signed-off-by: Mihai Maruseac <[email protected]> * Update README.md Signed-off-by: Mihai Maruseac <[email protected]> Signed-off-by: Mihai Maruseac <[email protected]>
1 parent 19030f3 commit e20f3cc

File tree

4 files changed

+220
-137
lines changed

4 files changed

+220
-137
lines changed

README.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ Below is a list of options currently supported for binary blobs and container im
156156
```bash
157157
$ git clone [email protected]:slsa-framework/slsa-verifier.git
158158
$ go run ./cli/slsa-verifier/ verify-artifact --help
159-
Verifies SLSA provenance on an artifact blob
159+
Verifies SLSA provenance on artifact blobs given as arguments (assuming same provenance)
160160

161161
Usage:
162-
slsa-verifier verify-artifact [flags]
162+
slsa-verifier verify-artifact [flags] artifact [artifact..]
163163

164164
Flags:
165-
--build-workflow-input map[] [optional] a workflow input provided by a user at trigger time in the format 'key=value'. (Only for 'workflow_dispatch' events). (default map[])
165+
--build-workflow-input map[] [optional] a workflow input provided by a user at trigger time in the format 'key=value'. (Only for 'workflow_dispatch' events on GitHub Actions). (default map[])
166166
--builder-id string [optional] the unique builder ID who created the provenance
167167
-h, --help help for verify-artifact
168168
--print-provenance [optional] print the verified provenance to stdout
@@ -173,6 +173,8 @@ Flags:
173173
--source-versioned-tag string [optional] expected version the binary was compiled from. Uses semantic version to match the tag
174174
```
175175

176+
Multiple artifacts can be passed to `verify-artifact`. As long as they are all covered by the same provenance file, the verification will succeed.
177+
176178
### Option details
177179

178180
The following options are available:
@@ -205,6 +207,27 @@ The verified in-toto statement may be written to stdout with the `--print-proven
205207

206208
Only GitHub URIs are supported with the `--source-uri` flag. A tag should not be specified, even if the provenance was built at some tag. If you intend to do source versioning validation, use `--print-provenance` and inspect the commit SHA of the config source or materials.
207209

210+
Multiple artifacts built from the same GitHub builder can be verified in the same command, by passing them in the same command line as arguments:
211+
212+
```bash
213+
$ slsa-verifier verify-artifact \
214+
--provenance-path /tmp/demo/multiple.intoto.jsonl \
215+
--source-uri github.com/mihaimaruseac/example \
216+
/tmp/demo/fib /tmp/demo/hello
217+
218+
Verified signature against tlog entry index 9712459 at URL: https://rekor.sigstore.dev/api/v1/log/entries/24296fb24b8ad77a1544828b67bb5a2335f7e0d01c504a32ceb6f3a8814ed12c8f1b222d308bd9e8
219+
Verified build using builder https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@refs/tags/v1.4.0 at commit 11fab87c5ee6f46c6f5e68f6c5378c62ce1ca77c
220+
Verifying artifact /tmp/demo/fib: PASSED
221+
222+
Verified signature against tlog entry index 9712459 at URL: https://rekor.sigstore.dev/api/v1/log/entries/24296fb24b8ad77a1544828b67bb5a2335f7e0d01c504a32ceb6f3a8814ed12c8f1b222d308bd9e8
223+
Verified build using builder https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@refs/tags/v1.4.0 at commit 11fab87c5ee6f46c6f5e68f6c5378c62ce1ca77c
224+
Verifying artifact /tmp/demo/hello: PASSED
225+
226+
PASSED: Verified SLSA provenance
227+
```
228+
229+
The only requirement is that the provenance file covers all artifacts passed as arguments in the command line (that is, they are a subset of `subject` field in the provenance file).
230+
208231
### Containers
209232

210233
This is WIP and currently not supported.

0 commit comments

Comments
 (0)