Skip to content

Commit 2170243

Browse files
authored
Fix cyclonedx bug (#213)
Signed-off-by: jiyeong.seok <[email protected]>
1 parent 0e07b67 commit 2170243

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/fosslight_util/correct.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,15 @@ def correct_with_yaml(correct_filepath, path_to_scan, scan_item):
6161

6262
yaml_path_exists = True
6363
exclude_fileitems.append(idx)
64-
65-
if not yaml_path_exists:
64+
if scanner_name == FOSSLIGHT_SOURCE and not yaml_path_exists:
6665
correct_item = copy.deepcopy(yaml_file_item)
6766
if os.path.exists(os.path.normpath(yaml_file_item.source_name_or_path)):
6867
correct_item.comment = 'Loaded from sbom-info.yaml'
6968
correct_fileitems.append(correct_item)
7069
else:
71-
if scanner_name == FOSSLIGHT_SOURCE:
72-
correct_item.exclude = True
73-
correct_item.comment = 'Added by sbom-info.yaml'
74-
correct_fileitems.append(correct_item)
70+
correct_item.exclude = True
71+
correct_item.comment = 'Added by sbom-info.yaml'
72+
correct_fileitems.append(correct_item)
7573
if correct_fileitems:
7674
scan_item.append_file_items(correct_fileitems, scanner_name)
7775
find_match = True

src/fosslight_util/write_cyclonedx.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
7373
comp_type = ComponentType.LIBRARY
7474

7575
for oss_item in file_item.oss_items:
76-
if oss_item.name == '':
76+
if oss_item.name == '' or oss_item.name == '-':
7777
if scanner_name == FOSSLIGHT_DEPENDENCY:
7878
continue
7979
else:
@@ -93,7 +93,8 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
9393
if scanner_name == FOSSLIGHT_DEPENDENCY and file_item.purl:
9494
comp.purl = PackageURL.from_string(file_item.purl)
9595
if scanner_name != FOSSLIGHT_DEPENDENCY:
96-
comp.hashes = [HashType(alg=HashAlgorithm.SHA_1, content=file_item.checksum)]
96+
if file_item.checksum != '0':
97+
comp.hashes = [HashType(alg=HashAlgorithm.SHA_1, content=file_item.checksum)]
9798

9899
if oss_item.download_location != '':
99100
comp.external_references = [ExternalReference(url=XsUri(oss_item.download_location),

0 commit comments

Comments
 (0)