@@ -149,12 +149,13 @@ def spdx_parse(file):
149
149
start = time .process_time ()
150
150
try :
151
151
document : Document = parse_file (file )
152
- print ('SPDX parsing took {:.2f}s' .format (time .process_time () - start ))
153
- return (document )
154
152
except SPDXParsingError :
155
153
logging .exception ("Failed to parse spdx file" )
156
154
sys .exit (1 )
157
155
156
+ print ('SPDX parsing took {:.2f}s' .format (time .process_time () - start ))
157
+ return (document )
158
+
158
159
# Validates the SPDX file. Logs all validation messages as warnings.
159
160
# Input: SPDX document object
160
161
def spdx_validate (document ):
@@ -198,7 +199,6 @@ def poll_for_upload(sbom_name):
198
199
}
199
200
cls = bd .get_resource ('codeLocations' , params = params )
200
201
for cl in cls :
201
- print (cl ['name' ])
202
202
# Force exact match of: spdx_doc_name + " spdx/sbom"
203
203
# BD appends the "spdx/sbom" string to the name.
204
204
if cl ['name' ] != sbom_name + " spdx/sbom" :
@@ -559,7 +559,7 @@ def main():
559
559
# Upload the provided SBOM
560
560
upload_sbom_file (args .spdx_file , args .project_name , args .version_name )
561
561
562
- # Wait for scan completeion . Will exit if it fails.
562
+ # Wait for scan completion . Will exit if it fails.
563
563
poll_for_upload (document .creation_info .name )
564
564
# Also exits on failure. This may be somewhat redundant.
565
565
poll_for_sbom_scan (document .creation_info .name , version )
@@ -591,14 +591,24 @@ def main():
591
591
# We hope we'll have an external reference (pURL), but we might not.
592
592
extref = None
593
593
purlmatch = False
594
+
595
+ if package .name == "" :
596
+ # Strange case where the package name is empty. Skip it.
597
+ logging .warning ("WARNING: package name empty, skipping" )
598
+ continue
599
+ # Trim any odd leading/trailing space or newlines
600
+ package .name = package .name .strip ()
601
+
594
602
# matchname/matchver can change, depending on the KB lookup step.
595
603
# These are stored separately to keep the original names handy
596
604
matchname = package .name
597
- if package .version is None :
605
+ if package .version is None or package . version == "" :
598
606
# Default in case one is not specified in SPDX
599
607
package .version = "UNKNOWN"
608
+ package .version = package .version .strip ()
600
609
matchver = package .version
601
- print (f"Processing SPDX package: { matchname } version: { matchver } ...." )
610
+ print (f"Processing SPDX package: { matchname } version: { matchver } ..." )
611
+
602
612
# Tracking unique package name + version combos from spdx file
603
613
packages [matchname + matchver ] = packages .get (matchname + matchver , 0 ) + 1
604
614
@@ -643,6 +653,8 @@ def main():
643
653
# - Do we need to add a version to an existing custom component?
644
654
nomatch += 1
645
655
print (f" Not present in BOM: { matchname } { matchver } " )
656
+
657
+ # Missing component data to write to a file for reference
646
658
comp_data = {
647
659
"name" : package .name ,
648
660
"spdx_id" : package .spdx_id ,
0 commit comments