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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly populate hasFiles field for spdx-json output #1156

Merged
merged 1 commit into from
Aug 11, 2022

Conversation

jedevc
Copy link
Contributor

@jedevc jedevc commented Aug 11, 2022

Heya 馃憢 Have been playing around with Syft recently, and came across some odd behavior! It looks like the hasFiles field isn't populating correctly, despite the relationships being in-place as expected, and there being logic to extract for this field.

Previously, extracting relationships between packages and files was not completing correctly, as SPDXRef- ElementIDs were being compared to raw IDs, and so never matched. This PR fixes this behavior, by ensuring that we always compare
ElementIDs.

I think the original behavior was introduced in #634, and while the unit tests pass, I can't find any integration tests that check the behavior - but would be happy to add one, if you have any pointers on where might be the best place! 馃帀

Let me know if there's anything else you need, happy to contribute!

@kzantow
Copy link
Contributor

kzantow commented Aug 11, 2022

Good catch @jedevc ! As for a test, maybe just add another unit test case in the to_format_model_test.go in the same package?

Previously, extracting relationships between packages and files was not
completing correctly, as SPDXRef- ElementIDs were being compared to raw
IDs, and so never matched. This patch ensures that we always compare
ElementIDs, to ensure that the hasFiles field is correctly populated.

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc
Copy link
Contributor Author

jedevc commented Aug 11, 2022

Actually, on second thoughts, fixing the test case that I broke from the change is hopefully good enough!

@kzantow
Copy link
Contributor

kzantow commented Aug 11, 2022

@jedevc agree -- looks like that test case should cover it just fine 馃憤

@kzantow kzantow merged commit 3db6911 into anchore:main Aug 11, 2022
aiwantaozi pushed a commit to aiwantaozi/syft that referenced this pull request Oct 20, 2022
Previously, extracting relationships between packages and files was not
completing correctly, as SPDXRef- ElementIDs were being compared to raw
IDs, and so never matched. This patch ensures that we always compare
ElementIDs, to ensure that the hasFiles field is correctly populated.

Signed-off-by: Justin Chadwell <me@jedevc.com>
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
Previously, extracting relationships between packages and files was not
completing correctly, as SPDXRef- ElementIDs were being compared to raw
IDs, and so never matched. This patch ensures that we always compare
ElementIDs, to ensure that the hasFiles field is correctly populated.

Signed-off-by: Justin Chadwell <me@jedevc.com>
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

Successfully merging this pull request may close these issues.

None yet

2 participants