Skip to content

Commit

Permalink
fix: Improved robustness of parser (fixes #26)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyharrison committed Jan 8, 2024
1 parent 45c891c commit a67211e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib4sbom/cyclonedx/cyclonedx_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ def __init__(self):

def parse(self, sbom_file):
"""parses CycloneDX BOM file extracting package name, version and license"""
if sbom_file.endswith("json"):
if sbom_file.endswith((".bom.json", ".cdx.json", ".json")):
return self.parse_cyclonedx_json(sbom_file)
else:
elif sbom_file.endswith((".bom.xml", ".cdx.xml", ".xml")):
return self.parse_cyclonedx_xml(sbom_file)
else:
return {}, {}, {}, [], []

def _governance_element(self, element):
elements = []
Expand Down

0 comments on commit a67211e

Please sign in to comment.