slsa-framework / slsa-verifier

Verify provenance from SLSA compliant builders
Apache License 2.0
232 stars 50 forks source link

feat: VerifyNpmPackage API with supplied tuf client #768

Open ramonpetgrave64 opened 6 months ago

ramonpetgrave64 commented 6 months ago

This PR

Offline rekor verification already works so long as the provenance is a valid sigstore bundle, though we could consider adding an explicit option to enforce offline rekor verifification.

Fixes #493

Testing

Followups

ramonpetgrave64 commented 6 months ago

@slugclub

ramonpetgrave64 commented 6 months ago

This is looking great, thanks so much for working on this. I have a few minor nits but overall it's looking good.

Thanks for the review! I was also looking into logging in https://github.com/slsa-framework/slsa-verifier/pull/772,

ramonpetgrave64 commented 6 months ago

@slugclub thanks again. @ianlewis @laurentsimon , please take a look

haydentherapper commented 5 months ago

cc @loosebazooka

ramonpetgrave64 commented 5 months ago

@loosebazooka

ramonpetgrave64 commented 4 months ago

@loosebazooka

loosebazooka commented 4 months ago

On the sigstore clients we actually just accept a trusted_root.json as an input to the verifier -- this would require depending on sigstore-go instead of cosign and I'm not sure where we're at here. However this eliminates the need for consumers to define a whole TUF client, they may compute trusted_root.json some other way.

haydentherapper commented 4 months ago

I could see a need for both - a user may gather their own root material out of band, at which point they should pass that material via a trusted root file, to align with the other Sigstore clients (and sigstore-go has an API for this). A developer integrating with the API may be opinionated on TUF settings and construct their own client (or pass options).

ramonpetgrave64 commented 4 months ago

I just don't think slsa-verifier should be involved in the lower-level details of the TUF client.

haydentherapper commented 3 months ago

I just don't think slsa-verifier should be involved in the lower-level details of the TUF client.

Could you say by what you mean on lower-level details? Do you mean the configuration of the TUF client?

In terms on an API, I think we could see a few different options:

ramonpetgrave64 commented 3 months ago

Could you say by what you mean on lower-level details? Do you mean the configuration of the TUF client?

I mean the trusted_root.json file, and managing potential refreshes in a long-running process.

  • A user who wants to configure certain settings for the TUF client - This would be a user who very much understands the implementation details of TUF and wants to control caching, which I don't think is likely, but could happen. An alternative is providing a TUF client.

But a user still has to know how to prepare a trusted_root.json properly. Ideally, the Sigstore TUF client can handle those cache-control options and make it easy for the user.

I would rather the user instead supply the trusted_root.json to their own TUF client, and then supply that to slsa-verifier.

For the CLI, if we wanted the same kind of customization, then supplying the trusted_root.json directly makes more sense, but we may still have to worry about refreshes. We can consider that feature later if there is community ask for it.

haydentherapper commented 3 months ago

I think there may be some conflation of "roots". https://pkg.go.dev/github.com/sigstore/sigstore-go@v0.5.1/pkg/tuf#Options.WithRoot refers to the TUF root, as in the root of trust for the TUF metadata. The "trusted root" is the Sigstore spec-compliant file that contains all of the roots of trust for the services within Sigstore's infra.

Regarding "we may still have to worry about refreshes", in the case that someone would supply a trusted root file directly, that effectively says "bypass TUF, don't worry about keeping metadata up to date".

For a user, they could either supply a TUF client which goes and fetches a "trusted root", or they supply the "trusted root" directly bypassing TUF (if they don't maintain their own TUF repo, for example, or want offline verification).

As for TUF caching options, I think that's mostly up to the library, and I don't think we must expose that right of the bat. Some users might be opinionated, so for example in Cosign, we allow disabling the cache, but we don't expose every TUF client option.

ramonpetgrave64 commented 3 months ago

Alright. For now, it's simpler and more flexible to the user for slsa-verifier to accept a sigstore TUF client.