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

fix(scan): CPE matching for OpenJDK packages #583

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pkg/sbom/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"os"
"path"
"strings"

"github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/cataloging/pkgcataloging"
Expand Down Expand Up @@ -157,6 +158,23 @@ func generateCPEs(p pkg.Package) []cpe.CPE {
return []cpe.CPE{dictionaryCPE}
}

// TODO: This is a workaround for Syft not coming up with this CPE for OpenJDK
// packages. Some thought would be needed on the "right" way to implement this
// upstream, but it's more obvious how we can address this in wolfictl for our
// purposes.
//
// Potentially related: https://github.com/anchore/syft/issues/2422
if strings.HasPrefix(p.Name, "openjdk-") {
return []cpe.CPE{
{
Part: "a",
Vendor: "oracle",
Product: "jdk",
Version: p.Version,
},
}
}

return cpegen.Generate(p)
}

Expand Down
Loading