Commit Graph

39 Commits

Author SHA1 Message Date
Mihai Maruseac
a72569a87a fix: Use Run instead of RunE to handle usage/errors (#424)
* Use `Run` instead of `RunE` to handle usage/errors

We want to only display the usage message if there is an error in the
parsing of arguments. Once the arguments are parsed and we invoke the
internal implementation the usage message should not be displayed
anymore, regardless of what internal error gets returned. Fortunately,
the fix is easy.

Tested:

* passing scenario:
```
[...]$ slsa-verifier verify-artifact \
       --provenance-path multiple.intoto.jsonl \
       --source-uri github.com/example/repo fib
Verified signature against tlog entry index 9712459 at URL: ...
Verified build using builder ...
Verifying artifact fib: PASSED

PASSED: Verified SLSA provenance
```

* failing scenario with missing artifact file:
```
[...]$ slsa-verifier verify-artifact \
       --provenance-path multiple.intoto.jsonl \
       --source-uri github.com/example/repo fibs
Verifying artifact fibs: FAILED: open fibs: no such file or directory

FAILED: SLSA verification failed: open fibs: no such file or directory
```

* failing scenario with invalid artifact:
```
[...]$ slsa-verifier verify-artifact \
       --provenance-path multiple.intoto.jsonl \
       --source-uri github.com/example/repo multiple.intoto.jsonl
Verified signature against tlog entry index 9712459 at URL: ...
Verifying artifact multiple.intoto.jsonl: FAILED: expected hash ...

FAILED: SLSA verification failed: expected hash ...
```

* failing scenario due to invalid usage (missing required arguments):
```
[...]$ slsa-verifier verify-artifact \
       --provenance-path multiple.intoto.jsonl
Usage:
  slsa-verifier verify-artifact [flags] artifact [artifact..]

Flags:
      --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[])
      --builder-id string             [optional] the unique builder ID who created the provenance
  -h, --help                          help for verify-artifact
      --print-provenance              [optional] print the verified provenance to stdout
      --provenance-path string        path to a provenance file
      --source-branch string          [optional] expected branch the binary was compiled from
      --source-tag string             [optional] expected tag the binary was compiled from
      --source-uri string             expected source repository that should have produced the binary, e.g. github.com/some/repo
      --source-versioned-tag string   [optional] expected version the binary was compiled from. Uses semantic version to match the tag

required flag(s) "source-uri" not set
exit status 1
```

Fixes #307

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Handle the same fix in image verification

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* go fmt

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>
2023-01-03 14:08:01 -06:00
Mihai Maruseac
17463c02b3 fix: Expect at least one artifact in verification (#426)
* fix: Expect at least one artifact in verification

Fixes #425 introduces by #419

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* go fmt

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>
2022-12-29 13:05:10 -08:00
Mihai Maruseac
e20f3cc7a3 feat: Verify all artifacts passed in cmdline (#419)
* Remove limit of number of artifacts to verify

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Update short description

Mention that we support multiple artifacts as long as they come from the
same provenance.

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Verify all artifacts passed in cmdline

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Remove header of verify step output

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Format the `cobra.Command.Use` argument

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* 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 <mihaimaruseac@google.com>

* Change existing tests to support multiple artifacts.

No new tests added, just changing table test data type.

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* [nfc] Format test file

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* 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 <mihaimaruseac@google.com>

* Fix typo

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Fix path to test artifacts

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Allow different provenance path

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Try 2 artifacts from existing testdata

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Add more tests for multiple artifacts

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Add failing test

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Fix artifact and error

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Add final test: no artifact match

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

* Update README.md

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>
2022-12-29 09:56:57 -08:00
Mihai Maruseac
8279f4bf4c Enhance help message (#418)
One part that is missing in the output if invocation is wrong is that
there is no indication that user has to pass path to a file
(artifact/image).

The remaining potential errors from #173 are handled via #231.

Found while looking at #174.

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>
2022-12-28 14:24:04 -06:00
Ian Lewis
f439833d5e Add regression build tag (#400)
Signed-off-by: Ian Lewis <ianlewis@google.com>
2022-12-15 01:25:04 +00:00
laurentsimon
4a6c5b1677 feat: add more tests for GCB verification (#389)
* update

Signed-off-by: laurentsimon <laurentsimon@google.com>

* update

Signed-off-by: laurentsimon <laurentsimon@google.com>

* update

Signed-off-by: laurentsimon <laurentsimon@google.com>

* update

Signed-off-by: laurentsimon <laurentsimon@google.com>

* update

Signed-off-by: laurentsimon <laurentsimon@google.com>

* update

Signed-off-by: laurentsimon <laurentsimon@google.com>

* update

Signed-off-by: laurentsimon <laurentsimon@google.com>

Signed-off-by: laurentsimon <laurentsimon@google.com>
2022-12-05 13:31:58 -08:00
asraa
d50e89b559 fix: handle workflow input flag parsing (#379)
* fix: handle workflow input flag parsing

Signed-off-by: Asra Ali <asraa@google.com>

* add smoke tests

Signed-off-by: Asra Ali <asraa@google.com>

Signed-off-by: Asra Ali <asraa@google.com>
2022-12-02 10:01:20 -08:00
Shunsuke Suzuki
74fd528309 fix: fix the Go package version to v2 (#373)
* fix: fix the package version to v2

```
git ls-files | grep ".go$" | xargs -n 1 gsed -i "s|github.com/slsa-framework/slsa-verifier|github.com/slsa-framework/slsa-verifier/v2|g"
```

Signed-off-by: Shunsuke Suzuki <suzuki.shunsuke.1989@gmail.com>

* fix: fix the package version to v2

Signed-off-by: Shunsuke Suzuki <suzuki.shunsuke.1989@gmail.com>

* test: fix source

Signed-off-by: Shunsuke Suzuki <suzuki.shunsuke.1989@gmail.com>

Signed-off-by: Shunsuke Suzuki <suzuki.shunsuke.1989@gmail.com>
2022-12-01 18:49:39 -08:00
Ian Lewis
28b554f525 Add golangci-lint and yamllint (#365)
* Add Makefile and yamllint config

Signed-off-by: Ian Lewis <ianmlewis@gmail.com>

* Add golangci-lint config

Signed-off-by: Ian Lewis <ianmlewis@gmail.com>

* Add golangci-lint config

Signed-off-by: Ian Lewis <ianmlewis@gmail.com>

* add linters to pre-submit

Signed-off-by: Ian Lewis <ianmlewis@gmail.com>

* add issue link to todos

Signed-off-by: Ian Lewis <ianmlewis@gmail.com>

* Fix whitespace issue

Signed-off-by: Ian Lewis <ianmlewis@gmail.com>

Signed-off-by: Ian Lewis <ianmlewis@gmail.com>
2022-11-28 10:19:59 +09:00
Ian Lewis
bbe98e8f2e Add e2e tests for slsa-github-generator v1.2.2 (#355)
* Add e2e tests for slsa-github-generator v1.2.2

* Fix testdata

Signed-off-by: Ian Lewis <ianmlewis@gmail.com>
2022-11-14 15:31:04 +00:00
asraa
ef0f1a7a24 refactor: consolidate verification funcs for GHA (#348)
* consolidate verification funcs

Signed-off-by: Asra Ali <asraa@google.com>
2022-11-02 15:32:39 -05:00
Wietse Venema
27597feff8 Add optional (#316)
* Update README.md

Add missing [optional] indicators to the "verify-artifact" --help example.

Signed-off-by: Wietse Venema <72045954+wietse-gmail@users.noreply.github.com>

* Add missing [optional] indicators to the verify-artifact help message

Signed-off-by: Wietse Venema <72045954+wietse-gmail@users.noreply.github.com>

Signed-off-by: Wietse Venema <72045954+wietse-gmail@users.noreply.github.com>
2022-10-23 23:33:39 +00:00
asraa
c151f47368 add v1.2.1 builder tests (#310)
Signed-off-by: Asra Ali <asraa@google.com>

Signed-off-by: Asra Ali <asraa@google.com>
2022-10-20 01:45:22 -07:00
asraa
6766be33a8 tests: fix builder id matching (#308)
* fix builder id matching

Signed-off-by: Asra Ali <asraa@google.com>
2022-10-18 16:02:08 -05:00
WhiteSource Renovate
4a8f4bd0d9 chore(deps): update gcr.io/distroless/base:nonroot docker digest to a6441d1 (#306) 2022-10-17 10:53:38 -05:00
WhiteSource Renovate
3ab86db547 chore(deps): update gcr.io/distroless/base:nonroot docker digest to 3778d4f (#293)
Co-authored-by: asraa <asraa@google.com>
2022-10-12 14:45:11 +00:00
asraa
936dc46aca ci: fix path to config (#297)
Signed-off-by: Asra Ali <asraa@google.com>

use k8s versioning to show commit and tree state

Signed-off-by: Asra Ali <asraa@google.com>

Signed-off-by: Asra Ali <asraa@google.com>
2022-10-08 18:31:10 +00:00
asraa
a6e069c0ab gcb: add gcb compatibility (#292)
Signed-off-by: Asra Ali <asraa@google.com>

Signed-off-by: Asra Ali <asraa@google.com>
2022-10-07 14:21:50 -07:00
laurentsimon
b5da86b168 doc: document build id and GCB vs GHA (#266)
* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* comments

* update
2022-09-23 19:04:51 +00:00
WhiteSource Renovate
eec5dd4c26 chore(deps): update gcr.io/distroless/base:nonroot docker digest to 33fac4d (#260)
Co-authored-by: asraa <asraa@google.com>
2022-09-19 20:43:51 +00:00
laurentsimon
533d347a4b feat: support builderID matching with or without semver for GHA (#257)
* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update
2022-09-15 14:32:03 -07:00
WhiteSource Renovate
11203e8546 chore(deps): update golang docker tag to v1.19 (#196) 2022-09-13 09:44:44 -05:00
laurentsimon
b58e752378 feat: support builderID matching with or without semver for GCB (#256)
* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update
2022-09-12 17:17:46 -07:00
laurentsimon
d12dce9526 feat: CLI tests for GCB verification (#251)
* update

* update

* update
2022-09-08 13:36:56 -07:00
asraa
26155fe9a3 fix: fix CLI flag mishap (#250)
Signed-off-by: Asra Ali <asraa@google.com>

Signed-off-by: Asra Ali <asraa@google.com>
2022-09-07 08:27:28 -07:00
asraa
ff0ced42ef refactor: add subcommands and separate functionality from artifacts a… (#231)
* refactor: add subcommands and separate functionality from artifacts and images

Signed-off-by: Asra Ali <asraa@google.com>
2022-09-06 17:10:58 -05:00
WhiteSource Renovate
0211941480 chore(deps): update golang:1.18 docker digest to 5540a6a (#238)
Co-authored-by: asraa <asraa@google.com>
2022-09-06 14:09:42 +00:00
laurentsimon
d5b56c334e feat: add CLI tests for GCB verification (#245)
* update

* update

* update

* update
2022-09-02 20:42:40 +00:00
laurentsimon
3b5c68f561 feat: Support for GCB verification (#202)
* add testing folder

Signed-off-by: Asra Ali <asraa@google.com>

* add tests

Signed-off-by: Asra Ali <asraa@google.com>

* update

* updated comments

Signed-off-by: Asra Ali <asraa@google.com>

* update

* update

* update

* update

* update

* update

* update

* draft

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

Signed-off-by: Asra Ali <asraa@google.com>
Co-authored-by: Asra Ali <asraa@google.com>
2022-08-24 10:17:14 -07:00
WhiteSource Renovate
77f8bc623b chore(deps): update gcr.io/distroless/base:nonroot docker digest to 533c15e (#228)
Co-authored-by: asraa <asraa@google.com>
2022-08-23 20:18:17 +00:00
WhiteSource Renovate
90406fa7ca chore(deps): update golang:1.18 docker digest to 616aa98 (#214)
Co-authored-by: laurentsimon <64505099+laurentsimon@users.noreply.github.com>
2022-08-19 19:04:44 +00:00
asraa
7b4b9cde06 feat: support oci image verification (#147)
* feat: support oci image verification

Signed-off-by: Asra Ali <asraa@google.com>

* add testing folder

Signed-off-by: Asra Ali <asraa@google.com>

* update name and make fix

Signed-off-by: Asra Ali <asraa@google.com>

* add tests

Signed-off-by: Asra Ali <asraa@google.com>

* Add initial testing

Signed-off-by: Asra Ali <asraa@google.com>

* updated comments

Signed-off-by: Asra Ali <asraa@google.com>

* update

Signed-off-by: Asra Ali <asraa@google.com>

* fix digest calculation

Signed-off-by: Asra Ali <asraa@google.com>

Signed-off-by: Asra Ali <asraa@google.com>
Co-authored-by: laurentsimon <64505099+laurentsimon@users.noreply.github.com>
2022-08-17 15:59:01 -05:00
laurentsimon
5bb13ef508 feat: add a -workflow-input option (#216)
* update
2022-08-15 19:38:15 +00:00
asraa
0de1860f7f fix: use experimental flag value 1 (#209)
Signed-off-by: Asra Ali <asraa@google.com>

Signed-off-by: Asra Ali <asraa@google.com>
2022-08-12 09:32:01 -07:00
laurentsimon
6790a1b311 feat: make builder-id flag experimental until fully tested (#207)
* update

* update
2022-08-11 19:46:04 +00:00
laurentsimon
4ca6320994 feat: make branch optional (#192)
* update

* update

* update

* update

* Update verifiers/internal/gha/provenance.go

Co-authored-by: Ian Lewis <ianlewis@google.com>

* update

* update

* update

* update

* update

* update

* update

* update

Co-authored-by: Ian Lewis <ianlewis@google.com>
2022-08-09 22:49:36 +00:00
laurentsimon
edb1ffd807 Never panic, always return error (#199)
* Update main.go

Signed-off-by: laurentsimon <64505099+laurentsimon@users.noreply.github.com>

* Update main.go

Signed-off-by: laurentsimon <64505099+laurentsimon@users.noreply.github.com>
2022-08-08 03:30:09 +00:00
laurentsimon
edb792b342 feat: Create interface for verifiers (#187)
* update

* update

* unit tests

* update

* comments

* update

* update

* update

* update

* Use interface for builders

* update

* update

* update

* update

* fix

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update
2022-08-05 14:31:34 -07:00
laurentsimon
caaf1c1b8e feat: Create a verifier as a service (#182)
* update

* update

* update

* tests

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* comments

* update

* update

* update

* update

* update
2022-08-03 14:29:25 -07:00