@@ -166,33 +166,37 @@ func (i *CyclonedxJSONCrafter) extractMetadata(m *api.Attestation_Material, meta
166166 i .logger .Debug ().Err (err ).Msg ("error extracting main component from sbom, skipping..." )
167167 }
168168
169- // Extract all tools from the array
170- for idx , tool := range meta . Tools {
171- m . Annotations [ AnnotationToolIndexedName ( idx )] = tool . Name
172- m . Annotations [ AnnotationToolIndexedVersion ( idx )] = tool .Version
169+ // Extract all tools and set annotations
170+ var tools [] Tool
171+ for _ , tool := range meta . Tools {
172+ tools = append ( tools , Tool { Name : tool .Name , Version : tool . Version })
173173 }
174+ SetToolsAnnotation (m , tools )
174175
175- // Maintain backward compatibility - keep legacy non-indexed keys for the first tool
176- if len (meta . Tools ) > 0 {
177- m .Annotations [AnnotationToolNameKey ] = meta . Tools [0 ].Name
178- m .Annotations [AnnotationToolVersionKey ] = meta . Tools [0 ].Version
176+ // Maintain backward compatibility - keep legacy keys for the first tool
177+ if len (tools ) > 0 {
178+ m .Annotations [AnnotationToolNameKey ] = tools [0 ].Name
179+ m .Annotations [AnnotationToolVersionKey ] = tools [0 ].Version
179180 }
181+
180182 case * cyclonedxMetadataV15 :
181183 if err := i .extractMainComponent (m , & meta .Component ); err != nil {
182184 i .logger .Debug ().Err (err ).Msg ("error extracting main component from sbom, skipping..." )
183185 }
184186
185- // Extract all tools from the array
186- for idx , tool := range meta . Tools . Components {
187- m . Annotations [ AnnotationToolIndexedName ( idx )] = tool . Name
188- m . Annotations [ AnnotationToolIndexedVersion ( idx )] = tool .Version
187+ // Extract all tools and set annotations
188+ var tools [] Tool
189+ for _ , tool := range meta . Tools . Components {
190+ tools = append ( tools , Tool { Name : tool .Name , Version : tool . Version })
189191 }
192+ SetToolsAnnotation (m , tools )
190193
191- // Maintain backward compatibility - keep legacy non-indexed keys for the first tool
192- if len (meta . Tools . Components ) > 0 {
193- m .Annotations [AnnotationToolNameKey ] = meta . Tools . Components [0 ].Name
194- m .Annotations [AnnotationToolVersionKey ] = meta . Tools . Components [0 ].Version
194+ // Maintain backward compatibility - keep legacy keys for the first tool
195+ if len (tools ) > 0 {
196+ m .Annotations [AnnotationToolNameKey ] = tools [0 ].Name
197+ m .Annotations [AnnotationToolVersionKey ] = tools [0 ].Version
195198 }
199+
196200 default :
197201 i .logger .Debug ().Msg ("unknown metadata version" )
198202 }
0 commit comments