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

Error message when parsing files and mandatory fields are missing. #155

Closed
kestewart opened this issue Dec 19, 2020 · 10 comments
Closed

Error message when parsing files and mandatory fields are missing. #155

kestewart opened this issue Dec 19, 2020 · 10 comments
Labels
parser Issues related to the parser layer

Comments

@kestewart
Copy link
Contributor

Using the tools.spdx.dev and feeding in file:

SPDXVersion: SPDX-2.2
DataLicense: CC0-1.0
SPDXID: SPDXRef-DOCUMENT-SAGPM
DocumentName: Software Assurance Guardian Point Man (SAG-PM)
DocumentNamespace: http://softwareassuranceguardian.com/
Creator: Person: Dick Brooks ([email protected]
Creator: Tool: PyInstaller 3.6
Created: 2020-09-08T19:44:17Z

Package: SAG-PM

PackageName:aiodns
SPDXID: SPDXRef-aiodns-2.0.0
PackageSupplier: Person:Saúl Ibarra Corretgé
PackageVersion: 2.0.0
PackageChecksum: SHA-256: aaa5ac584f40fe778013df0aa6544bf157799bd3f608364b451840ed2c8688de
PackageDownloadLocation: purl+pkg:pypi/[email protected]
FilesAnalyzed: false

PackageName:altgraph
SPDXID: SPDXRef-altgraph-0.17
PackageSupplier: Person:Ronald Oussoren
PackageVersion: 0.17
PackageChecksum: SHA-256: c623e5f3408ca61d4016f23a681b9adb100802ca3e3da5e718915a9e4052cebe
PackageLicenseConcluded: MIT
PackageDownloadLocation: purl+pkg:pypi/[email protected]
FilesAnalyzed: false

The error message, “Only one PackageName allowed, extra at line: 21” is confusing and misleading.
as I think the problem is missing mandatory fields. But please confirm if this is indeed the case.

@rjb4standards
Copy link

Kate, I have confirmed your speculation, adding the missing fields got me pass this error, perhaps an error like "Missing required fields { missing fields} would be more helpful. Thanks for your help.

@goneall
Copy link
Member

goneall commented Dec 20, 2020

Moving this over to the new version of the SPDX tools which is now used in the online tools.

@goneall goneall transferred this issue from spdx/tools Dec 20, 2020
@goneall
Copy link
Member

goneall commented Dec 20, 2020

I'm not able to reproduce the same error.

When I run validate using the above file text, I get an invalid document error due to the SPDX Document Ref.

The SPDXID: SPDXRef-DOCUMENT-SAGPM needs to be replaced with SPDXID: SPDXRef-DOCUMENT per the spec.

When I fix that, I get a different error:

image

Looking at the document, line 10 contains Package: SAG-PM which is not a valid keyword.

When I remove the invalid package, I get the following error:

Analysis exception processing SPDX file: Invalid checksum algorithm: SHA-256: aaa5ac584f40fe778013df0aa6544bf157799bd3f608364b451840ed2c8688de at line number 14

SHA-256 needs to be replaced with SHA256.

Fixing this, I get the error Analysis exception processing SPDX file: Invalid download location pattern purl+pkg:pypi/[email protected]. Must match the pattern ^(NONE|NOASSERTION|(((git|hg|svn|bzr)\+)?(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/|ssh:\/\/|git:\/\/|svn:\/\/|sftp:\/\/|ftp:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*))|(git\+git@[a-zA-Z0-9\.]+:[a-zA-Z0-9]+)|(bzr\+lp:[a-zA-Z0-9\.]+))$

Removing the download location, I got the following message:

This SPDX Document is not valid due to:
	Package at line 17 invalid: Missing required copyright text for altgraph in altgraph
	Package at line 17 invalid: Missing required download location for package altgraph
	Package at line 17 invalid: Missing required declared license for package altgraph
	Package at line 10 invalid: Missing required concluded license for aiodns in aiodns
	Package at line 10 invalid: Missing required copyright text for aiodns in aiodns
	Package at line 10 invalid: Missing required download location for package aiodns
	Package at line 10 invalid: Missing required declared license for package aiodns

BTW - I did find a separate issue parsing external Ref's while investigating this, issue spdx/spdx-java-tagvalue-store#3

@rjb4standards
Copy link

Thanks, Gary. I'll tackle these issues. Is there an online, web spdx verifier I can use to check for errors?

@goneall
Copy link
Member

goneall commented Dec 20, 2020

@rjb4standards Yes - https://tools.spdx.org/app/validate/

I thought that was the origin of these errors.

Are you using the command line tool at https://github.com/spdx/tools?

If so, you can try a more up to date command line tool at https://github.com/spdx/tools-java

@goneall
Copy link
Member

goneall commented Dec 20, 2020

@rjb4standards Were these error found using the Python parser? If so, you can ignore all my comments above on the error handling and I'll transfer this over to the Python tools repo.

@rjb4standards
Copy link

Gary, yhe Python parser is reporting these errors, but the online validator, my new best friend, reports no errors.
PackageName:spdx-tools
SPDXID: SPDXRef-spdx-tools-0.6.1
PackageSupplier: Person:Ahmed H. Ismail
PackageVersion: 0.6.1
PackageChecksum: SHA256: 45fa09d43534772ca63bff2dccf1fbde88e1fc9b9515fc7a34ae50540d7ad29c

@goneall
Copy link
Member

goneall commented Dec 20, 2020

Moving this issue to the Python tools repo

@goneall goneall transferred this issue from spdx/spdx-java-tagvalue-store Dec 20, 2020
@meretp
Copy link
Collaborator

meretp commented Oct 17, 2022

This issue seems to be related to #185. Feeding the python parser with the file from above with the mentioned fixes leads to the error:

PackageChecksum must be a single line of text, line: 15
PackageChecksum must be a single line of text, line: 23
Errors while parsing:  True

@meretp meretp added the parser Issues related to the parser layer label Oct 20, 2022
@meretp
Copy link
Collaborator

meretp commented Jan 10, 2023

With the current release, the mentioned file can be parsed without errors, so I will close this issue.

@meretp meretp closed this as completed Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Issues related to the parser layer
Projects
None yet
Development

No branches or pull requests

4 participants