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

feat: testing mode from non-main slsa-framework/slsa-github-generator branches #797

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
allow slsa-framework/slsa-github-generator provenances from other bra…
…nches in testing mode

Signed-off-by: Ramon Petgrave <[email protected]>
  • Loading branch information
ramonpetgrave64 committed Aug 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a702bf7bd2cdfbcf6c44917c0ae0d4b86032ea43
7 changes: 7 additions & 0 deletions verifiers/internal/gha/provenance.go
Original file line number Diff line number Diff line change
@@ -330,6 +330,13 @@ func isValidDelegatorBuilderID(prov iface.Provenance) error {
}
}

// Exception for slsa-framework/slsa-github-generator branches during testing mode

Choose a reason for hiding this comment

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

I think I would prefer maybe your other suggestion that the user defines the verification repo path in their test rather than modifying the normal behavior of the code conditionally.

Copy link
Member

Choose a reason for hiding this comment

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

The alternate suggestion is maybe fine as long as it only works if SLSA_VERIFIER_TESTING is explicitly enabled. This prints warning messages etc. if IIRC.

// to allow provenance from non-main to be verified, such as during development.
normalizedSLSAGithubGeneratorRepoURI := utils.NormalizeGitURI(httpsGithubCom + trustedBuilderRepository)
if options.TestingEnabled() && normalizedURI == utils.NormalizeGitURI(normalizedSLSAGithubGeneratorRepoURI) {
return nil
}

return utils.IsValidBuilderTag(builderRef, false)
}

12 changes: 12 additions & 0 deletions verifiers/internal/gha/provenance_test.go
Original file line number Diff line number Diff line change
@@ -471,6 +471,18 @@ func Test_isValidDelegatorBuilderID(t *testing.T) {
builderID: "some/builderID@refs/heads/main",
testingEnabled: true,
},
{
name: "invalid builder: ref slsa-github-generator repo: testing enabled",
sourceURI: gitPrefix + httpsGithubCom + "slsa-framework/slsa-github-generator",
builderID: "some/builderID@refs/heads/anybranch",
testingEnabled: true,
},
{
name: "invalid builder: ref slsa-github-generator repo: testing disabled",
sourceURI: gitPrefix + httpsGithubCom + "slsa-framework/slsa-github-generator",
builderID: "some/builderID@refs/heads/anybranch",
err: serrors.ErrorInvalidRef,
},
{
name: "invalid builder ref e2e repo",
sourceURI: gitPrefix + httpsGithubCom + e2eTestRepository,
Loading