@@ -123,11 +123,6 @@ func (r *RekorVSARetriever) searchForImageDigest(ctx context.Context, imageDiges
123123 return entries , nil
124124}
125125
126- // GetAllEntriesForImageDigest returns all entries for an image digest without VSA filtering
127- func (r * RekorVSARetriever ) GetAllEntriesForImageDigest (ctx context.Context , imageDigest string ) ([]models.LogEntryAnon , error ) {
128- return r .searchForImageDigest (ctx , imageDigest )
129- }
130-
131126// decodeBodyJSON decodes the base64-encoded body of a Rekor entry
132127func (r * RekorVSARetriever ) decodeBodyJSON (entry models.LogEntryAnon ) (map [string ]any , error ) {
133128 bodyStr , ok := entry .Body .(string )
@@ -170,17 +165,6 @@ func isValidImageDigest(digest string) bool {
170165 return err == nil
171166}
172167
173- // IsValidHexHash validates that a string is a valid hex hash
174- func (r * RekorVSARetriever ) IsValidHexHash (hash string ) bool {
175- if len (hash ) == 0 {
176- return false
177- }
178-
179- // Check if it's a valid hex string
180- _ , err := hex .DecodeString (hash )
181- return err == nil
182- }
183-
184168// classifyEntryKind determines the kind of a Rekor entry (intoto, intoto-v002, dsse, etc.)
185169func (r * RekorVSARetriever ) classifyEntryKind (entry models.LogEntryAnon ) string {
186170 // Prefer Body structure from the decoded Rekor body
@@ -257,46 +241,6 @@ func (r *RekorVSARetriever) classifyEntryKind(entry models.LogEntryAnon) string
257241 return "unknown"
258242}
259243
260- // ExtractStatementFromIntoto extracts the Statement JSON from an in-toto entry
261- func (r * RekorVSARetriever ) ExtractStatementFromIntoto (entry * models.LogEntryAnon ) ([]byte , error ) {
262- if entry == nil {
263- return nil , fmt .Errorf ("entry cannot be nil" )
264- }
265-
266- // Check if this is an in-toto entry
267- entryKind := r .classifyEntryKind (* entry )
268- if entryKind != "intoto" {
269- return nil , fmt .Errorf ("entry is not an in-toto entry (kind: %s)" , entryKind )
270- }
271-
272- // Extract the DSSE envelope from the entry
273- envelopeBytes , err := r .extractDSSEEnvelopeFromEntry (entry )
274- if err != nil {
275- return nil , fmt .Errorf ("failed to extract DSSE envelope from entry: %w" , err )
276- }
277-
278- // Parse the DSSE envelope
279- var envelope map [string ]interface {}
280- if err := json .Unmarshal (envelopeBytes , & envelope ); err != nil {
281- return nil , fmt .Errorf ("failed to parse DSSE envelope: %w" , err )
282- }
283-
284- // Extract the payload
285- payloadBase64 , ok := envelope ["payload" ].(string )
286- if ! ok {
287- return nil , fmt .Errorf ("payload not found in DSSE envelope" )
288- }
289-
290- // Decode the base64 payload
291- payloadBytes , err := base64 .StdEncoding .DecodeString (payloadBase64 )
292- if err != nil {
293- return nil , fmt .Errorf ("failed to decode base64 payload: %w" , err )
294- }
295-
296- // The payload should contain the Statement JSON
297- return payloadBytes , nil
298- }
299-
300244// extractDSSEEnvelopeFromEntry extracts the DSSE envelope from a Rekor entry
301245func (r * RekorVSARetriever ) extractDSSEEnvelopeFromEntry (entry * models.LogEntryAnon ) ([]byte , error ) {
302246 // Determine entry type first
@@ -356,48 +300,6 @@ func (r *RekorVSARetriever) extractDSSEEnvelopeFromEntry(entry *models.LogEntryA
356300 return nil , fmt .Errorf ("could not extract DSSE envelope from entry" )
357301}
358302
359- // extractVSAStatement extracts the VSA Statement from an in-toto entry
360- func (r * RekorVSARetriever ) extractVSAStatement (entry models.LogEntryAnon ) ([]byte , error ) {
361- // Check if this is an in-toto 0.0.2 entry (single entry)
362- entryKind := r .classifyEntryKind (entry )
363- if entryKind == "intoto-v002" {
364- // For in-toto 0.0.2 entries, the payload is directly in the Attestation field
365- if entry .Attestation == nil || entry .Attestation .Data == nil {
366- return nil , fmt .Errorf ("in-toto 0.0.2 entry does not contain attestation data" )
367- }
368-
369- // The attestation data contains the decoded payload (VSA statement)
370- log .Debugf ("Extracting VSA statement from in-toto 0.0.2 entry attestation" )
371- return entry .Attestation .Data , nil
372- }
373-
374- // For dual entries (in-toto 0.0.1 + DSSE), use the existing logic
375- envelopeBytes , err := r .extractDSSEEnvelopeFromEntry (& entry )
376- if err != nil {
377- return nil , fmt .Errorf ("failed to extract DSSE envelope: %w" , err )
378- }
379-
380- var envelope map [string ]interface {}
381- if err := json .Unmarshal (envelopeBytes , & envelope ); err != nil {
382- return nil , fmt .Errorf ("failed to parse DSSE envelope: %w" , err )
383- }
384-
385- // Extract the payload
386- payloadBase64 , ok := envelope ["payload" ].(string )
387- if ! ok {
388- return nil , fmt .Errorf ("payload not found in DSSE envelope" )
389- }
390-
391- // Decode the base64 payload
392- payloadBytes , err := base64 .StdEncoding .DecodeString (payloadBase64 )
393- if err != nil {
394- return nil , fmt .Errorf ("failed to decode base64 payload: %w" , err )
395- }
396-
397- // The payload should contain the Statement JSON
398- return payloadBytes , nil
399- }
400-
401303// RetrieveVSA retrieves VSA data as a DSSE envelope for a given image digest
402304// This is the main method used by validation functions to get VSA data for signature verification
403305func (r * RekorVSARetriever ) RetrieveVSA (ctx context.Context , imageDigest string ) (* ssldsse.Envelope , error ) {
0 commit comments