Skip to content

Commit

Permalink
docs: added docstring to swid_parser.py (#3716)
Browse files Browse the repository at this point in the history
* closes #3712
  • Loading branch information
Mahhheshh committed Jan 17, 2024
1 parent 9e386cd commit 470e206
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cve_bin_tool/sbom_manager/swid_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@


class SWIDParser:
"""
Class responsible for parsing SWID (Software Identification Tags) XML BOM (Bill of Materials) files.
"""

def __init__(self, validate: bool = True):
self.validate = validate

Expand All @@ -35,6 +39,13 @@ def parse(self, sbom_file: str) -> list[list[str]]:
return modules

def extract(self, swid: str) -> list[str]:
"""
Extracts the product name and version from a SWID entry.
args:
swid: SWID entry
returns:
list containing product name and version
"""
# Return parsed swid entry as [product, version] list item
# Format of swid is "URI: <vendor>-<product>-<version>"
item = swid[swid.find(":") + 1 :].split("-")
Expand Down

0 comments on commit 470e206

Please sign in to comment.