Skip to content

Prune errata references dropped upstream - #1274

Open
anfimovdm wants to merge 1 commit into
masterfrom
al-errata-references-prune
Open

anfimovdm wants to merge 1 commit into
masterfrom
al-errata-references-prune

Conversation

@anfimovdm

Copy link
Copy Markdown
Contributor

Summary

POST /api/v1/errata/update_references/ was add-only. When Red Hat drops a wrongly attributed CVE or bugzilla from an advisory, public-errata-parser's refresh can't remove it, so it stays on our errata and in the published updateinfo.xml. Scanners then report the CVE as fixed by an AlmaLinux advisory that doesn't fix it.

This adds an opt-in prune flag. With it, the payload is taken as the advisory's complete upstream reference set, and stored cve/bugzilla references missing from it are removed. rhsa and self references are never pruned.

Changes

  • alws/schemas/errata_schema.py: UpdateErrataReferencesRequest.prune, default False, so existing callers keep the add-only behaviour.
  • alws/crud/errata.py:
    • add_missing_errata_references() → sync_errata_references(). It adds the missing references as before, and with prune it removes the stale cve/bugzilla ones. It returns the added and removed ref_ids.
    • Stale references are removed with a bulk SQL DELETE on purpose. Both NewErrataReference relationships use cascade="all, delete", so an ORM delete would also delete the errata record and the ErrataCVE row, which other advisories share. Deleting that row would in turn cascade, through its FK, into those advisories' references.
    • append_references_in_update_records() → sync_references_in_update_records(). It now also deletes Pulp cve/bugzilla references that aren't on the DB record anymore, so released advisories match the DB.
  • alws/routers/errata.py: a released record is reconciled in Pulp (the update_errata_references actor, whose signature is unchanged) when references were added or removed.

Testing

  • tests/test_api/test_errata.py: new test covering add, no-prune (nothing removed), prune (only the dropped CVE goes, rhsa/bugzilla/self stay), a repeated prune, and the ErrataCVE row and errata record surviving the removal.
  • tests/test_unit/test_errata.py: new test for the Pulp reference sync (stale cve/bugzilla deleted, self kept, missing ones appended).
  • Full suite (without tests/test_oval, as in run-tests.sh): 303 passed, 10 skipped.

Deployment

Can be deployed independently of the parser change. Old ALBS ignores the unknown prune field, and old parser versions never send it.

update_references was add-only, so a CVE or bugzilla Red Hat removed from an advisory stayed on our errata and in the published updateinfo.xml. With the new opt-in prune flag, stored cve/bugzilla references missing from the payload are removed from the DB record and from already released Pulp advisories, which are then republished. rhsa and self references are never pruned.

References are bulk deleted on purpose: both NewErrataReference relationships cascade deletes, so an ORM delete would also remove the advisory and the ErrataCVE row shared with other advisories.
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.

1 participant