-
Notifications
You must be signed in to change notification settings - Fork 117
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
feat: build config can specify package CPE #1768
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Dan Luhring <[email protected]>
pkg/config/config.go
Outdated
|
||
// String returns a CPE string for the package. | ||
func (c CPE) String() string { | ||
return fmt.Sprintf("cpe:2.3:a:%s:%s:*:*:*:*:*:*:*:*", c.Vendor, c.Product) |
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.
Is there more we might want to be able to fill out? I never remember CPE semantics, but I think it's also got version range info, and we have version info. Can we use it in any way?
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.
Yeah definitely. It can do versions (not ranges), so we can plug in the .Package.Version
field from the Configuration
struct. Nothing's calling this String()
method yet, but if someone does, they'd get the benefit of that.
Same goes for other fields. We could add them all now, if we want. I was curious if it'd be better to wait and see which we end up needing (I'd bet money we don't need them all), but no opinion here.
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.
Arch & os helps.
As in x86_64 & Linux. Do not want windows-only CVEs and similar.
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'm not against adding those two, but I will say:
- I almost never see those set on CVE records. I'm not sure people know how to use them. And for OS, more often I see the CVE record using boolean groups of multiple CPEs, rather than trying to convey the OS in a single CPE.
- From the perspective of scanning, which is the big motivation here, by the time we're looking at a package, we already know the architecture and that it's Linux, so we don't really need the package itself to tell us that.
Since this comes straight from the Package struct, we need a method on the Package struct to handle this instead of a method on CPE. Signed-off-by: Dan Luhring <[email protected]>
Added to $ tar -xOf ./packages/aarch64/cosign-2.4.1-r5.apk .PKGINFO
# Generated by melange
pkgname = cosign
pkgver = 2.4.1-r5
arch = aarch64
size = 84551068
origin = cosign
pkgdesc = Container Signing
url =
commit = 54fac0d402f48b3e3ae8ed08fa0be0bea9d5923a
builddate = 1737155808
license = Apache-2.0
depend = ca-certificates-bundle
provides = cmd:cosign=2.4.1-r5
# cpe = cpe:2.3:*:sigstore:cosign:2.4.1:*:*:*:*:*:*:*
datahash = 5fe105545021b762f52f908592194cbf9dea87f4e724010282738b24f6100630 |
Signed-off-by: Dan Luhring <[email protected]>
Some "devil's advocate" thoughts are occurring to me about this whole approach:
Sanity checking welcome! 😅 |
This draft PR is trying out an idea where a package's build config could specify its own CPE values. Today our scanning system maintains its own list of known CPEs for packages with certain names. But perhaps it's better if each package is capable of defining the correct CPE on its own (if it has a CPE), which would remove the need for us to keep a central list up to date.
Improving CPE identification for packages will help us find CVEs for packages better (specifically, by improving recall) because it's not always possible to derive the correct CPE just from the package's other metadata.
Example of how this might look for cosign, for example:
We could add other CPE fields over time as we find the need.
Should we use this CPE information in the package's SBOM as well? Probably. Although there's an argument to be made that finding this data in the built package's
.melange.yaml
is easier (and perhaps less likely to change shapes in the future) than finding it in the/var/lib/db/sbom/...
location.