Skip to content

WIP: Scanning: add support for CPE catalog which maps packages to repositories - #158

Draft
vojtapolasek wants to merge 5 commits into
ComplianceAsCode:mainfrom
vojtapolasek:cpe-catalog-fix
Draft

vojtapolasek wants to merge 5 commits into
ComplianceAsCode:mainfrom
vojtapolasek:cpe-catalog-fix

Conversation

@vojtapolasek

Copy link
Copy Markdown
Collaborator
 - Add cvetool catalog to generate a JSON catalog from selected RHEL repositories.
 - Query package NEVRAs through DNF, including both the requested architecture and noarch packages.
 - Store repository-to-CPE mappings and catalog metadata
 - Add scan --catalog to load and apply catalog data before vulnerability matching.
 - Validate catalog RHEL version and architecture against the scanned system.
 - Enrich matching environments with exact-NEVRA repository/CPE information.
 - Advise users to generate and use a catalog when a scan finds no vulnerabilities.
 - Add unit, integration, CLI, and regression coverage for catalog generation and scan enrichment.

This is rather a draft. It is working, but if accepted, there are plans for further enhancements and possibly simplifications.

Generate an online catalog from explicitly selected repository IDs and store it as plain JSON. Index exact NEVRA matches, preserve repository-to-CPE metadata for offline scanning, and keep the catalog proof of concept free of a second database format.
Add catalog generation CLI wiring and scan-time enrichment. Configure Claircore with a local repository mapping, validate catalog compatibility, and attach exact-NEVRA CPEs only to the matching package environments before vulnerability matching.
Keep the catalog regression test and local fixtures in the shared branch without including the private VM reproducer documentation. The test still proves the exact krb5-libs NEVRA is missed without repository CPE context and reported after catalog enrichment.

@Mab879 Mab879 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After

Comment thread cmd/cvetool/catalog.go

var catalogCmd = &cli.Command{
Name: "catalog",
Usage: "generate an RHEL package catalog",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add an alias like scan.

Aliases: []string{"s"},

Comment thread cmd/cvetool/catalog.go
},
&cli.StringFlag{
Name: "arch",
Usage: "package architecture to catalog",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After doing some playing on my RHEL boxes, seems you can't get info for other arches. So I propose we drop this and send the arch we running on to the catalog creator.

Comment thread cmd/cvetool/catalog.go
Usage: "package architecture to catalog",
},
&cli.StringSliceFlag{
Name: "repo-id",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be required? Can make not required for RHEL?

Comment thread cmd/cvetool/catalog.go
Action: generateCatalog,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "rhel-version",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think you can get info from other RHEL versions info. Is this even needed?

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