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

Taking too much time to verify the SPDX tag-value SBOM #161

Closed
boravinod145 opened this issue May 14, 2024 · 3 comments
Closed

Taking too much time to verify the SPDX tag-value SBOM #161

boravinod145 opened this issue May 14, 2024 · 3 comments

Comments

@boravinod145
Copy link

boravinod145 commented May 14, 2024

Description

An invalid Tag value SBOM contains large relationships and has thousands of SPDX warnings taking exponential time to verify.

Example

To generate this issue download the attached spdx tag value file is an invalid SBOM and try to verify it:

SBOM: issued.zip

java -jar tools-java-1.1.8-jar-with-dependencies.jar Verify ./issued.spdx

I waited for 5 hours and it is still not validated. After debugging this, found verifying elements in relationships in line L1489 in spdx-java-tagvalue-store lib is taking too much time to verify the relationships.

To verify this I've created a new jar by commenting lines L1488C3-L1490C4, is verified the same SBOM within 1 min.

@goneall
Copy link
Member

goneall commented May 21, 2024

Thanks @boravinod145 for the detailed analysis.

I took a look at the code and it wasn't obvious to me how it got stuck - likely some kind of (nearly) infinite recursion.

The verify for relationship will include a verification of the element being referenced.

There is code in the library to avoid infinite recursion as relationships can form cycles in valid SPDX documents.

We could avoid validating the element by changing the code on L1489 to:

			verifyElement(entry.getValue().verify(new HashSet<>(Arrays.asList(new String[] {entry.getValue().getRelatedSpdxElement().get().getId()})), 
					this.specVersion), "Relationship", entry.getKey());

It feels a bit hacky and I'm a bit concerned I'm not completely understanding the error - but this would a marginally better than removing the check.

@bact
Copy link
Collaborator

bact commented Dec 21, 2024

With 2.0.0-RC1, does this one still an issue?

@goneall
Copy link
Member

goneall commented Dec 21, 2024

I just tried verifying the SPDX file in the issued.zip file and it took 14 minutes on my laptop. It is still quite a long time, but there are 41,000 relationships to verify which is what is taking the time.

Note that this is primarily an issue with the tag/value parser since it needs to validate each relationship inside the tag/value parser. Other formats should take about half the time.

I'll go ahead and close it. @boravinod145 - if you still are running into a performance problem, please open a new issue.

@goneall goneall closed this as completed Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants