diff --git a/enricher/epss/epss.go b/enricher/epss/epss.go index 97e96db32..d931633e3 100644 --- a/enricher/epss/epss.go +++ b/enricher/epss/epss.go @@ -165,20 +165,7 @@ func (e *Enricher) FetchEnrichment(ctx context.Context, _ driver.Fingerprint) (i continue // Skip lines with mismatched number of fields } - item := make(map[string]string) - for i, value := range record { - item[headers[i]] = value - } - - enrichment, err := json.Marshal(item) - if err != nil { - return nil, "", fmt.Errorf("failed to encode enrichment: %w", err) - } - - r := driver.EnrichmentRecord{ - Tags: []string{item["cve"]}, - Enrichment: enrichment, - } + r, err := newItemFeed(ctx, record, headers) if err = enc.Encode(&r); err != nil { return nil, "", fmt.Errorf("failed to write JSON line to file: %w", err) @@ -294,3 +281,22 @@ func (e *Enricher) Enrich(ctx context.Context, g driver.EnrichmentGetter, r *cla } return Type, []json.RawMessage{b}, nil } + +func newItemFeed(ctx context.Context, record []string, headers []string) (driver.EnrichmentRecord, error) { + item := make(map[string]string) + for i, value := range record { + item[headers[i]] = value + } + + enrichment, err := json.Marshal(item) + if err != nil { + return driver.EnrichmentRecord{}, fmt.Errorf("failed to encode enrichment: %w", err) + } + + r := driver.EnrichmentRecord{ + Tags: []string{item["cve"]}, + Enrichment: enrichment, + } + + return r, nil +}