Skip to content

use Syft for decoding CPEs#3058

Merged
kzantow merged 3 commits intoanchore:mainfrom
chovanecadam:feat-list-cpes
Mar 17, 2026
Merged

use Syft for decoding CPEs#3058
kzantow merged 3 commits intoanchore:mainfrom
chovanecadam:feat-list-cpes

Conversation

@chovanecadam
Copy link
Copy Markdown
Contributor

Makes use of new API in Syft for decoding CPEs and enables reading a file with CPEs for scan.

I deleted tests in grype/pkg/cpe_provider_test.go as they are the same as in syft (see here). It doesn't make sense to me to have the same test the same functionality in two places, but let me know if you want it some other way.

Comment thread grype/pkg/cpe_provider.go
}{
{
name: "takes a single cpe",
userInput: "cpe:/a:apache:log4j:2.14.1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of this test can be removed, but we should leave at least one cpe: example to validate that it is correctly returning the expected package; maybe one with each CPE format cpe:2.3:a:apache:log4j:2.14.1:*:*:*:*:*:*:* and cpe:/a:apache:log4j:2.14.1. I think this single-CPE case is not tested if this file is removed, is it tested elsewhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file with test cases is in Syft already (see here), so I removed it to not replicate code. I can add a few sanity-check test cases for a single CPEs in both formats and multiple CPEs. Sounds good?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, acknowledge that Syft testing is important and handles most of the cases, but by removing this test file we don't have anything directly testing this cpeProvider, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, will do

Adam Chovanec added 2 commits January 28, 2026 10:58
Signed-off-by: Adam Chovanec <git@adamchovanec.cz>
Signed-off-by: Adam Chovanec <git@adamchovanec.cz>
@chovanecadam
Copy link
Copy Markdown
Contributor Author

How can we move this forward? Is there anything I can do? @kzantow

Signed-off-by: Keith Zantow <kzantow@gmail.com>
Copy link
Copy Markdown
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this; thanks for making the requested updates! I pushed one small change to restore a test of specifying CPE 2.3, I hope you don't mind.

@kzantow kzantow merged commit c362b4c into anchore:main Mar 17, 2026
12 checks passed
@kzantow kzantow added the bug Something isn't working label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants