@@ -100,7 +100,7 @@ func GetComponentRelation(bom *cyclonedx.BOM, componentRef string, skipDefaultRo
100100 if bom == nil || bom .Components == nil {
101101 return UnknownRelation
102102 }
103- component := SearchComponentByRefGitDiff (bom .Components , componentRef )
103+ component := SearchComponentByRef (bom .Components , componentRef )
104104 if component == nil || component .Type != cyclonedx .ComponentTypeLibrary {
105105 // The component is not found in the BOM components or not library, return UnknownRelation
106106 return UnknownRelation
@@ -260,12 +260,12 @@ func SearchComponentByRef(components *[]cyclonedx.Component, ref string) (compon
260260 return
261261}
262262
263- func SearchComponentByRefGitDiff (components * []cyclonedx.Component , ref string ) (component * cyclonedx.Component ) {
263+ func SearchComponentByCleanPurl (components * []cyclonedx.Component , purl string ) (component * cyclonedx.Component ) {
264264 if components == nil || len (* components ) == 0 {
265265 return
266266 }
267267 for i , comp := range * components {
268- if techutils .PurlToXrayComponentId (comp .BOMRef ) == techutils .PurlToXrayComponentId (ref ) {
268+ if techutils .PurlToXrayComponentId (comp .PackageURL ) == techutils .PurlToXrayComponentId (purl ) {
269269 return & (* components )[i ]
270270 }
271271 }
@@ -321,7 +321,7 @@ func Exclude(bom cyclonedx.BOM, componentsToExclude ...cyclonedx.Component) (fil
321321 }
322322 filteredSbom = & bom
323323 for _ , compToExclude := range componentsToExclude {
324- if matchedBomComp := SearchComponentByRefGitDiff (bom .Components , compToExclude .BOMRef ); matchedBomComp == nil || GetComponentRelation (& bom , matchedBomComp .BOMRef , false ) == RootRelation {
324+ if matchedBomComp := SearchComponentByCleanPurl (bom .Components , compToExclude .BOMRef ); matchedBomComp == nil || GetComponentRelation (& bom , matchedBomComp .BOMRef , false ) == RootRelation {
325325 // If not a match or Root component, skip it
326326 continue
327327 }
0 commit comments