@@ -11,11 +11,6 @@ import (
1111 "slices"
1212 "strings"
1313
14- "github.com/carabiner-dev/attestation"
15- "github.com/carabiner-dev/collector"
16- "github.com/carabiner-dev/collector/envelope"
17- "github.com/carabiner-dev/collector/repository/github"
18- "github.com/carabiner-dev/collector/repository/note"
1914 "github.com/spf13/cobra"
2015 "google.golang.org/protobuf/encoding/protojson"
2116
@@ -59,61 +54,6 @@ func (po *pushOptions) AddFlags(cmd *cobra.Command) {
5954 cmd .PersistentFlags ().StringSliceVar (& po .pushLocation , "push" , []string {}, fmt .Sprintf ("Push signed attestations to storage %v" , supportedPushRepos ))
6055}
6156
62- func (po * pushOptions ) GetCollectorAgent (opts commitOptions , token string ) (* collector.Agent , error ) {
63- if len (po .pushLocation ) == 0 {
64- return nil , nil
65- }
66-
67- // Create the attestation storage repositories
68- agent , err := collector .New ()
69- if err != nil {
70- return nil , err
71- }
72-
73- for _ , uri := range po .pushLocation {
74- var repo attestation.Repository
75- var err error
76-
77- // Translate just "note" or "github" to the full repo spec acting on
78- // the sepcified commit
79- switch uri {
80- case note .TypeMoniker :
81- uri = fmt .Sprintf (
82- "note:git+https://github.com/%s/%s@%s" ,
83- opts .owner , opts .repository , opts .commit ,
84- )
85- case github .TypeMoniker :
86- uri = fmt .Sprintf ("github:%s/%s" , opts .owner , opts .repository )
87- }
88- switch {
89- case strings .HasPrefix (uri , "github:" ):
90- repo , err = github .New (
91- // Initialize the github repository
92- github .WithInit (uri ),
93- // We pass the token to use in the githu client
94- github .WithToken (token ),
95- )
96- case strings .HasPrefix (uri , "note:" ):
97- repo , err = note .New (
98- // Initialize the notes repository
99- note .WithInit (uri ),
100- // Push is enabled as we will append the note to the remote
101- note .WithPush (true ),
102- // Push via http, using the GH access token
103- note .WithHttpAuth ("x-access-token" , token ),
104- )
105- default :
106- return nil , fmt .Errorf ("repository type not supported" )
107- }
108- if err != nil {
109- return nil , fmt .Errorf ("creating storage repository: %w" , err )
110- }
111- agent .AddRepository (repo ) //nolint:errcheck,gosec // always returns nil
112- }
113-
114- return agent , nil
115- }
116-
11757type checkLevelProvOpts struct {
11858 commitOptions
11959 verifierOptions
@@ -187,18 +127,15 @@ and pushed to its remote (--push=note).
187127 return err
188128 }
189129
190- t , err := authenticator .ReadToken ()
191- if err != nil {
192- return err
193- }
194-
195130 // Create a new sourcetool object
196131 srctool , err := sourcetool .New (
197132 sourcetool .WithAuthenticator (authenticator ),
198133 sourcetool .WithAllowMergeCommits (opts .allowMergeCommits ),
134+ sourcetool .WithNotesStorer (slices .Contains (opts .pushLocation , "notes" )),
135+ sourcetool .WithGithubStorer (slices .Contains (opts .pushLocation , "github" )),
199136 )
200137 if err != nil {
201- return err
138+ return fmt . Errorf ( "creating sourcetool: %w" , err )
202139 }
203140
204141 // Create the provenance attestation
@@ -272,30 +209,6 @@ and pushed to its remote (--push=note).
272209 return fmt .Errorf ("writing bundle data: %w" , err )
273210 }
274211 }
275-
276- cl , err := opts .GetCollectorAgent (opts .commitOptions , t )
277- if err != nil {
278- return fmt .Errorf ("creating storage repositories: %w" , err )
279- }
280-
281- // If there are any storage repositories configured, push the attestations
282- if cl != nil {
283- // Parse the attestations into envelopes
284- envProv , err := envelope .Parsers .Parse (strings .NewReader (signedProv ))
285- if err != nil || len (envProv ) == 0 {
286- return fmt .Errorf ("parsing provenance: %w" , err )
287- }
288- envVsa , err := envelope .Parsers .Parse (strings .NewReader (signedVsa ))
289- if err != nil || len (envVsa ) == 0 {
290- return fmt .Errorf ("parsing VSA: %w" , err )
291- }
292-
293- // And store them
294- err = cl .Store (cmd .Context (), []attestation.Envelope {envProv [0 ], envVsa [0 ]})
295- if err != nil {
296- return fmt .Errorf ("storing attestations: %w" , err )
297- }
298- }
299212 default :
300213 log .Printf ("unsigned prov: %s\n " , unsignedProv )
301214 log .Printf ("unsigned vsa: %s\n " , unsignedVsa )
0 commit comments