-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update spdx_parser.py to handle spdx file parsing logic to generate correct key value pair of dictionary #5
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,16 +34,31 @@ def parse_spdx_tag(self, sbom_file): | |
packages = {} | ||
package = "" | ||
version = None | ||
githubStr = "pkg.go.dev/" | ||
for line in lines: | ||
line_elements = line.split(":") | ||
if line_elements[0] == "PackageName": | ||
isProductNameWithOnlyVersionNumber = False | ||
package = line_elements[1].strip().rstrip("\n") | ||
productNameWithOnlyVersionNumber = re.compile(r'(/)') | ||
if bool(productNameWithOnlyVersionNumber.search(package)) != True: | ||
isProductNameWithOnlyVersionNumber = True | ||
version = None | ||
license = None | ||
if line_elements[0] == "PackageVersion": | ||
version = line[16:].strip().rstrip("\n") | ||
if line_elements[0] == "PackageLicenseConcluded": | ||
license = line_elements[1].strip().rstrip("\n") | ||
if line_elements[0] == "PackageHomePage": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we add this check,we also need to do a corresponding check for all formats of SBOMs not just SPDX tag value SBOMs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I will add same check for json, xml, yaml and rdf. |
||
packageHomePage = line_elements[1].strip().rstrip("\n") | ||
packageHomePageRemaining = "" | ||
if len(line_elements) > 2 : | ||
packageHomePageRemaining = line_elements[2].strip().rstrip("\n") | ||
packageHomePage = packageHomePage + packageHomePageRemaining | ||
if isProductNameWithOnlyVersionNumber: | ||
tempArry = packageHomePage.split(githubStr) | ||
if len(tempArry) == 2: | ||
package = tempArry[1] | ||
if package not in packages and version is not None and license is not None: | ||
packages[package] = [version, license] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not appropriate as this only works for Go packages. sbomdiff needs to be generic for all SBOMs and languages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree I will add some check to do this only for GO libs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you suggest how to find packages for other language like java, python etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a valid change,
The differences in package name is due to the differences in the SBOM generator. Comparing SBOMs from different generators is a valid use case and I can see how useful it is to detect that the generators are creating different names for the same package. Trying to make sbomdiff cater for different generators and establish that the different package names are actually the same package is beyond the scope of sbomdiff as it is not viable to accommodate the approaches adopted by all the different SBOM generators for generating package names.