@@ -13,6 +13,7 @@ import (
1313 "strings"
1414 "time"
1515
16+ v1 "github.com/in-toto/attestation/go/predicates/vsa/v1"
1617 spb "github.com/in-toto/attestation/go/v1"
1718 "google.golang.org/protobuf/encoding/protojson"
1819 "google.golang.org/protobuf/proto"
@@ -24,9 +25,14 @@ import (
2425 "github.com/slsa-framework/source-tool/pkg/slsa"
2526)
2627
28+ type ProvenanceAttestorOptions struct {
29+ VsaRetries uint8
30+ }
31+
2732type ProvenanceAttestor struct {
2833 verifier Verifier
2934 gh_connection * ghcontrol.GitHubConnection
35+ Options ProvenanceAttestorOptions
3036}
3137
3238func NewProvenanceAttestor (gh_connection * ghcontrol.GitHubConnection , verifier Verifier ) * ProvenanceAttestor {
@@ -267,10 +273,22 @@ func (pa ProvenanceAttestor) CreateTagProvenance(ctx context.Context, commit, re
267273 // Find the most recent VSA for this commit. Any reference is OK.
268274 // TODO: in the future get all of them.
269275 // TODO: we should actually verify this vsa: https://github.com/slsa-framework/source-tool/issues/148
270- vsaStatement , vsaPred , err := GetVsa (ctx , pa .gh_connection , pa .verifier , commit , ghcontrol .AnyReference )
271- if err != nil {
272- return nil , fmt .Errorf ("error fetching VSA when creating tag provenance %w" , err )
276+ var tries uint8
277+ var vsaStatement * spb.Statement
278+ var vsaPred * v1.VerificationSummary
279+ for {
280+ vsaStatement , vsaPred , err = GetVsa (ctx , pa .gh_connection , pa .verifier , commit , ghcontrol .AnyReference )
281+ if err != nil {
282+ return nil , fmt .Errorf ("error fetching VSA when creating tag provenance %w" , err )
283+ }
284+
285+ tries ++
286+ if tries >= pa .Options .VsaRetries || vsaPred != nil {
287+ break
288+ }
289+ time .Sleep (time .Duration (tries * 5 ) * time .Second )
273290 }
291+
274292 if vsaPred == nil {
275293 // TODO: If there's not a VSA should we still issue provenance?
276294 return nil , nil
0 commit comments