Skip to content

Commit ee1f5c6

Browse files
authored
Handle missing VSA when generating tag provenance (#403)
Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev>
1 parent e93c7aa commit ee1f5c6

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/attest/provenance.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ func (a *Attester) CreateTagProvenance(ctx context.Context, branch *models.Branc
347347

348348
if vsaAtt == nil {
349349
// TODO: If there's not a VSA, should we still issue provenance?
350+
// No VSA for the tagged commit: return a nil statement so the caller can
351+
// report it. This usually means the commit's source provenance was never
352+
// generated (or could not be read) before the tag was created.
353+
Debugf("no VSA found for tagged commit %s, cannot build tag provenance", tag.Commit.SHA)
350354
return nil, nil
351355
}
352356

pkg/sourcetool/tool.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,16 @@ func (t *Tool) AttestRevision(
451451
return nil, err
452452
}
453453

454+
// Tag provenance is built from the VSA of the tagged commit. If that
455+
// commit has no VSA, CreateTagProvenance returns a nil statement and here
456+
// we fail with a clear message instead of a downstream "nil statement" error.
457+
if prov == nil {
458+
return nil, fmt.Errorf(
459+
"no VSA found for tagged commit %s; ensure its source provenance was generated before tagging",
460+
rev.GetCommit().SHA,
461+
)
462+
}
463+
454464
// 2. Run the provenance against the policy to determine the verified levels.
455465
pe := policy.NewPolicyEvaluator()
456466
pe.UseLocalPolicy = opts.LocalPolicy

0 commit comments

Comments
 (0)