Skip to content

feat(sbom): generate CPE for PM specific components#151

Merged
nervgh merged 2 commits into
mainfrom
feat/sbom/cpe-generation
Jul 6, 2026
Merged

feat(sbom): generate CPE for PM specific components#151
nervgh merged 2 commits into
mainfrom
feat/sbom/cpe-generation

Conversation

@reyreavman

Copy link
Copy Markdown
Collaborator

No description provided.

Add github.com/facebookincubator/nvdtools (wfn subpackage) to build and
validate CPE 2.3 identifiers for pm-managed components.

wfn provides the Well-Formed CPE Name binding (BindToFmtString) and
parser (UnbindFmtString) used by the new pkg/sbom/cpe package, which
ports the vendor/product heuristics from Anchore syft without depending
on the full syft module. Pulling all of syft was rejected because its
dependency tree bumps docker/buildah to versions incompatible with
werf's pinned forks. Net effect is a single new direct dependency.

Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
Add pkg/sbom/cpe, which infers CPE 2.3 identifiers for pm-managed
components using vendor/product heuristics ported from Anchore syft on
top of nvdtools/wfn:

  - URL-to-vendor extraction (github/gitlab owner, curated host prefixes)
  - curated vendor/product overrides (curl->haxx, brotli->google, ...)
  - upstream name normalization (strip -devel/-libs/-dev, stream version)
  - hyphen<->underscore delimiter variations and separator sub-selections
  - trailing-digit variations and known-vendor (apache) preference
  - specificity-based ordering

Package binaries built by pm are typed pkg:generic in the SBOM;
vulnerability scanners match those C/C++ components through CPE rather
than purl, so without a CPE they get no CVE matches. The delimiter and
sub-selection variations widen recall to the forms NVD actually records.

os_pm attaches the most specific CPE to component.cpe and the remaining
candidates as evidence.identity. pm components keep flowing through the
external-reference resolver (which understands the containerFactoryVersion
purl qualifier) — the CPE is additive and does not change that path.

Copied heuristics carry Apache-2.0 attribution to syft; see NOTICE.

Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
@reyreavman reyreavman force-pushed the feat/sbom/cpe-generation branch from e84b4ba to 7eec323 Compare July 6, 2026 08:11
Comment thread pkg/sbom/cpe/generate.go
return vendor
}

func uniqueStrings(values ...string) []string {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's replace with lo.uniq

@nervgh nervgh merged commit b6298e6 into main Jul 6, 2026
14 of 15 checks passed
@nervgh nervgh deleted the feat/sbom/cpe-generation branch July 6, 2026 09:36
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.

2 participants