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

EPSS enricher #1439

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

EPSS enricher #1439

wants to merge 4 commits into from

Conversation

daynewlee
Copy link
Contributor

@daynewlee daynewlee commented Nov 12, 2024

Epss enricher should be able to update, parse EPSS data and enrich vulnerability report with the data

@daynewlee daynewlee force-pushed the yli3/epssUpdater branch 6 times, most recently from e876194 to 32941b1 Compare November 13, 2024 18:49

const (
// Type is the type of data returned from the Enricher's Enrich method.
Type = `message/vnd.clair.map.vulnerability; enricher=clair.epss schema=https://csrc.nist.gov/schema/nvd/feed/1.1/cvss-v3.x.json`
Copy link
Contributor Author

@daynewlee daynewlee Nov 13, 2024

Choose a reason for hiding this comment

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

converting CSV file to json, not sure what the Type should look like.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we need to point to an actual schema here

@daynewlee daynewlee force-pushed the yli3/epssUpdater branch 3 times, most recently from f5058ef to 7fbe5d3 Compare November 14, 2024 22:01
@daynewlee daynewlee changed the title EPSS updater EPSS enricher Nov 15, 2024
@daynewlee daynewlee force-pushed the yli3/epssUpdater branch 2 times, most recently from 34f4e08 to 5f69717 Compare November 17, 2024 21:32
@daynewlee daynewlee marked this pull request as ready for review November 17, 2024 21:33
@daynewlee daynewlee requested a review from a team as a code owner November 17, 2024 21:33
@daynewlee daynewlee requested review from crozzy, RTann and jvdm and removed request for a team November 17, 2024 21:33
@daynewlee daynewlee changed the title EPSS enricher ROX-27045: EPSS enricher Nov 19, 2024
@daynewlee daynewlee changed the title ROX-27045: EPSS enricher EPSS enricher Nov 19, 2024
@daynewlee
Copy link
Contributor Author

As of Nov 20th, we decide to include model version and score date in the enrichment data

enricher/epss/epss.go Show resolved Hide resolved
enricher/epss/epss.go Outdated Show resolved Hide resolved
enricher/epss/epss.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
ctx = zlog.ContextWithValues(ctx, "component", "enricher/epss/Enricher/Configure")
var cfg Config
e.c = c
if f == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will leave this to @crozzy but I see there is no precedence for nil checking, and in the current usage, any nil function is replaced with a noop one

enricher/epss/epss.go Outdated Show resolved Hide resolved
enricher/epss/epss.go Outdated Show resolved Hide resolved
enricher/epss/epss.go Outdated Show resolved Hide resolved
return Type, []json.RawMessage{b}, nil
}

func newItemFeed(record []string, headers []string, modelVersion string, scoreDate string) (driver.EnrichmentRecord, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

will review this once the other comments are resolved

enricher/epss/epss_test.go Show resolved Hide resolved
@daynewlee daynewlee force-pushed the yli3/epssUpdater branch 3 times, most recently from 9525df0 to 6bdb39d Compare November 22, 2024 16:38
//
// It allows for "CVE" to be case insensitive and for dashes and underscores
// between the different segments.
var cveRegexp = regexp.MustCompile(`(?i:cve)[-_][0-9]{4}[-_][0-9]{4,}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a copy, we should find a place (probably within the enrichment package) where this will live.

"github.com/quay/claircore"
"github.com/quay/claircore/libvuln/driver"
"github.com/quay/claircore/pkg/tmp"
"github.com/quay/zlog"
Copy link
Contributor

Choose a reason for hiding this comment

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

This still needs to be updated to format @RTann described


const (
// Type is the type of data returned from the Enricher's Enrich method.
Type = `message/vnd.clair.map.vulnerability; enricher=clair.epss schema=https://csrc.nist.gov/schema/nvd/feed/1.1/cvss-v3.x.json`
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we need to point to an actual schema here

enricher/epss/epss.go Outdated Show resolved Hide resolved
enricher/epss/epss.go Outdated Show resolved Hide resolved
enricher/epss/epss.go Outdated Show resolved Hide resolved
func (e *Enricher) FetchEnrichment(ctx context.Context, _ driver.Fingerprint) (io.ReadCloser, driver.Fingerprint, error) {
ctx = zlog.ContextWithValues(ctx, "component", "enricher/epss/Enricher/FetchEnrichment")
newUUID := uuid.New()
hint := driver.Fingerprint(newUUID.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

The updaters are going to run multiple times per day so wouldn't the data be the same in subsequent requests a lot of the time? If yes, we should use the etag/fingerprint to determine if anything has changed, and if not, don't bother processing again.

enricher/epss/epss.go Outdated Show resolved Hide resolved
enricher/epss/epss.go Outdated Show resolved Hide resolved
item := make(map[string]interface{}) // Use interface{} to allow mixed types
for i, value := range record {
// epss details are numeric values
if f, err := strconv.ParseFloat(value, 64); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there certain known values that will not parse into floats that we'd still want?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think originally value here was string type

@daynewlee daynewlee force-pushed the yli3/epssUpdater branch 2 times, most recently from 4709a48 to 411d044 Compare December 1, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants