@@ -160,6 +160,9 @@ def poll_for_upload(sbom_name):
160
160
# -- operatinName: Scanning
161
161
# Search for the latest scan matching our SBOM
162
162
# This might be a risk for a race condition
163
+ # TODO Annoyingly, the sbom_name is not necessarily precisely our document
164
+ # name! Found a case where BD swaps a space for a "-" in the
165
+ # document name.
163
166
params = {
164
167
'q' : [f"name:{ sbom_name } " ],
165
168
'sort' : ["updatedAt: ASC" ]
@@ -551,11 +554,20 @@ def add_to_sbom(proj_version_url, comp_ver_url):
551
554
packages [matchname + matchver ] = packages .get (matchname + matchver , 0 ) + 1
552
555
553
556
if package .external_references :
554
- # TODO need to handle the possiblity of:
555
- # A) multiple extrefs
556
- # B) an extref that is not a purl
557
- # -- referenceType should be "purl" - ignore others?
558
- kb_match = find_comp_in_kb (package .external_references [0 ].locator )
557
+ foundpurl = False
558
+ kb_match = None
559
+ for ref in package .external_references :
560
+ # There can be multiple extrefs - try to locate a purl
561
+ if (ref .reference_type == "purl" ):
562
+ # TODO are we guaranteed only 1 purl?
563
+ # what would it mean to have >1?
564
+ foundpurl = True
565
+ kb_match = find_comp_in_kb (ref .locator )
566
+ extref = ref .locator
567
+ break
568
+ if not foundpurl :
569
+ nopurl += 1
570
+ print (f" No pURL provided for { package .name } { package .version } " )
559
571
if (kb_match ):
560
572
# Update package name and version to reflect the KB name/ver
561
573
print (f" KB match for { package .name } { package .version } " )
0 commit comments