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: Print byob builder #677

Merged
merged 3 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
pull_request:
types: [opened, edited, reopened, synchronize]

permissions: read-all

jobs:
validate:
runs-on: ubuntu-latest
Expand Down
18 changes: 18 additions & 0 deletions verifiers/internal/gha/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,24 @@ func isValidDelegatorBuilderID(prov iface.Provenance) error {
return utils.IsValidBuilderTag(parts[1], false)
}

// builderID returns the trusted builder ID from the provenance.
// The certTrustedBuilderID input is from the Fulcio certificate.
func builderID(env *dsselib.Envelope, certTrustedBuilderID *utils.TrustedBuilderID) (*utils.TrustedBuilderID, error) {
prov, err := slsaprovenance.ProvenanceFromEnvelope(certTrustedBuilderID.Name(), env)
if err != nil {
return nil, err
}
id, err := prov.BuilderID()
if err != nil {
return nil, err
}
verifiedBuilderID, err := utils.TrustedBuilderIDNew(id, true)
if err != nil {
return nil, err
}
return verifiedBuilderID, nil
}

// VerifyProvenance verifies the provenance for the given DSSE envelope.
func VerifyProvenance(env *dsselib.Envelope, provenanceOpts *options.ProvenanceOpts, trustedBuilderID *utils.TrustedBuilderID, byob bool) error {
prov, err := slsaprovenance.ProvenanceFromEnvelope(trustedBuilderID.Name(), env)
Expand Down
11 changes: 10 additions & 1 deletion verifiers/internal/gha/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,18 @@ func verifyEnvAndCert(env *dsse.Envelope,
return nil, nil, err
}

if byob {
// Overwrite the builderID to match the one in the provenance.
verifiedBuilderID, err = builderID(env, verifiedBuilderID)
if err != nil {
return nil, nil, err
}
}

fmt.Fprintf(os.Stderr, "Verified build using builder %q at commit %s\n",
workflowInfo.SubjectWorkflow.String(),
verifiedBuilderID.String(),
workflowInfo.SourceSha1)

// Return verified provenance.
r, err := base64.StdEncoding.DecodeString(env.Payload)
if err != nil {
Expand Down
Loading