Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcb: add gcb compatibility for provenance formats and buckets #292

Merged
merged 1 commit into from
Oct 7, 2022

Conversation

asraa
Copy link
Contributor

@asraa asraa commented Oct 7, 2022

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

This PR does two things in order to achieve GCB provenance compatibility:

  1. Adds support for incorrect string/int JSON for intoto. I temporarily vendor the GCB provenance and omit the definedInMaterial field. Until GCB updates their provenance generation, this will have to do.
  2. Also adds support for GCS versioned buckets. I spoke with the GCB team: v0.3 does not necessarily produce level 3 provenance, and we can only guarantee the provenance requirements (up to non-falsifiability for v0.3). We should definitely prioritize a versioning option in the future that would disallow generating provenance in a lower level mannger.

Adds testcase for the JSON marshalling issue and the GCS Buckets.

Signed-off-by: Asra Ali <asraa@google.com>
@inferno-chromium inferno-chromium merged commit a6e069c into slsa-framework:main Oct 7, 2022
Copy link
Member

@ianlewis ianlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit late but for posterity.

Type string `json:"type"`
// DefinedInMaterial can be sent as the null pointer to indicate that
// the value is not present.
// DefinedInMaterial *int `json:"definedInMaterial,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a short local comment as to why this is commented out. Maybe point to comment at top of file.

@@ -0,0 +1,68 @@
package gcb

// Copy of github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/v0.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a "NOTE: " prefix to the comment.

if !strings.HasPrefix(expectedSourceURI, "https://") {

// It is possible that GCS builds at level 2 use GCS sources, prefixed by gs://.
if strings.HasPrefix(uri, "https://") && !strings.HasPrefix(expectedSourceURI, "https://") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You might also leave a note as to why this is necessary in the first place. It's not necessarily obvious why "https://" might need to be prefixed at the beginning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, consider checking for any URI scheme rather than "https://" specifically. So you don't end up with strange URIs like "https://http://example.com/..." if the user enters "--source http://example.com"

Suggested change
if strings.HasPrefix(uri, "https://") && !strings.HasPrefix(expectedSourceURI, "https://") {
if strings.HasPrefix(uri, "https://") && !strings.HasPrefix(expectedSourceURI, "://") {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants