Skip to content

Resolve "Create an EPSS ingestion service"

Yasha Rise requested to merge 470856-create-an-epss-ingestion-service-2 into master

What does this MR do and why?

This MR implements only the ingestion task area of EPSS data so it may be consumed by GitLab instances from PMDB and the pm_epss table may be populated.

Handles Create an EPSS ingestion service (#470856 - closed) • Yasha Rise • 17.5 • On track.

Database changes

There is a new query added through ee/app/services/package_metadata/ingestion/cve_enrichment/cve_enrichment_ingestion_task.rb:

        def execute
          PackageMetadata::Epss.bulk_upsert!(valid_cve_enrichment_entries, unique_by: %w[cve],
            returns: %w[id cve score created_at updated_at])
        end

The query may look like so:

INSERT INTO "pm_epss" ("score", "created_at", "updated_at", "cve")
    VALUES (0.1, '2024-09-16 13:01:22.542899', '2024-09-16 13:01:22.542899', 'CVE-4321-4321'),
    (0.2, '2024-09-16 13:01:22.542899', '2024-09-16 13:01:22.542899', 'CVE-4321-43210'),
    (0.3, '2024-09-16 13:01:22.542899', '2024-09-16 13:01:22.542899', 'CVE-4321-53210')
ON CONFLICT ("cve")
    DO UPDATE SET
        "score" = excluded."score", "updated_at" = excluded."updated_at"
    RETURNING
        "id", "cve", "score", "created_at", "updated_at"

A query plan for a request with 500 entries, some updated and some new:

                                                    QUERY PLAN
------------------------------------------------------------------------------------------------------------------
 Insert on pm_epss  (cost=0.00..7.50 rows=500 width=64) (actual time=0.143..7.367 rows=500 loops=1)
   Conflict Resolution: UPDATE
   Conflict Arbiter Indexes: index_pm_epss_on_cve
   Tuples Inserted: 245
   Conflicting Tuples: 255
   ->  Values Scan on "*VALUES*"  (cost=0.00..7.50 rows=500 width=64) (actual time=0.019..0.616 rows=500 loops=1)
 Planning Time: 0.742 ms
 Execution Time: 7.428 ms
(8 rows)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Related to #470856 (closed)

Edited by Yasha Rise

Merge request reports

Loading