Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added docstring to swid_parser.py #3716

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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