Skip to content

Commit

Permalink
fix: add debug to CycloneDX parser
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyharrison committed Aug 20, 2024
1 parent e8b90db commit e5cd241
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib4sbom/cyclonedx/cyclonedx_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ def parse_cyclonedx_json(self, sbom_file):
else:
cyclonedx_document.set_value("bom_version", 1)
if "metadata" in data:
if self.debug:
print ("Processing Metadata")
if "timestamp" in data["metadata"]:
cyclonedx_document.set_created(data["metadata"]["timestamp"])
if "lifecycles" in data["metadata"]:
Expand Down Expand Up @@ -509,10 +511,18 @@ def parse_cyclonedx_json(self, sbom_file):
cyclonedx_document.set_value(
"property", data["metadata"]["properties"]
)
if self.debug:
print (cyclonedx_document)
if "components" in data:
if self.debug:
print ("Processing Components")
for d in data["components"]:
self._cyclondex_component(d)
if self.debug:
print (self.packages)
if "dependencies" in data:
if self.debug:
print ("Processing Dependencies")
for d in data["dependencies"]:
source_id = d["ref"]
# Get source name
Expand All @@ -538,7 +548,11 @@ def parse_cyclonedx_json(self, sbom_file):
elif self.debug:
print(f"[ERROR] Unable to find {target_id}")
relationship_type = " DEPENDS_ON "
if self.debug:
print(relationships)
if "vulnerabilities" in data:
if self.debug:
print ("Processing Vulnerabilities")
vuln_info = Vulnerability(validation="cyclonedx")
for vuln in data["vulnerabilities"]:
vuln_info.initialise()
Expand Down Expand Up @@ -580,6 +594,8 @@ def parse_cyclonedx_json(self, sbom_file):
if self.debug:
print(vulnerabilities)
if "services" in data:
if self.debug:
print ("Processing Services")
service_info = SBOMService()
service_id=1
for service in data["services"]:
Expand Down

0 comments on commit e5cd241

Please sign in to comment.