Repository navigation
feat(priority): store what decides a rank, and rank the stored listings - #61
Closed
maksimtech wants to merge 1 commit into
Closed
maksimtech wants to merge 1 commit into
maksimtech wants to merge 1 commit into
Conversation
CISA's exploitation facts and the CVSS v4.0 exploit maturity travelled in the scan's records and were not columns: the next `status` listed by publication date, and an exploited CVE from 2023 sat under every new 5.3. test_priority_wiring held that boundary to say "now rank the database paths too" the day the columns arrived. - cves gains known_exploited, kev_ransomware, kev_date_added, kev_due_date and cvss_exploit_maturity, migrated in place and refreshed by every scan that brings them: CISA lists a CVE long after NVD publishes it. CISA's "Unknown" is stored as no. - get_cves orders by priority.sql_order, built from the constants priority() decides with; an index on that order makes the full listing 1.0 ms on the benchmark's 500 CVEs, against 1.45 ms by date. - /api/cves rows carry priority, priority_reason and the KEV fields; status has a Priority column and lists most urgent first. - test_priority_wiring now holds the other side of the boundary. Tests first, seen failing; the SQL order is checked against sort_by_priority on rows covering every rank and edge. 15 of 16 mutants killed; the survivor drops the "scored" branch, which COALESCE on the score already orders the same way (equivalent). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Owner
Author
|
Folded into #64, which now targets main with every commit of the stack: one review, one merge, no conflicts from squash merges. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Audit finding PR-01, step 01b-3 (docs/DESIGN.md §5.5). Stacked on #60, which is stacked on #59: review in order #59 → #60 → this. After each squash merge I'll retarget the next one to
main.What was wrong
known_exploited,kev_ransomware, the KEV dates and the CVSS v4.0 exploit maturity travelled in the scan's records and were not columns. The nextpatchradar status, and/api/cves, listed by publication date, so an exploited CVE from 2023 sat under every new 5.3.test_priority_wiring.pyheld that boundary on purpose, to say "now rank the database paths too" the day the columns arrived.What changes
cvesgainsknown_exploited,kev_ransomware,kev_date_added,kev_due_dateandcvss_exploit_maturity, migrated in place.COALESCE: a row NVD stored on Monday learns on Wednesday that CISA listed it, and a scan whose keyword KEV does not match does not erase the fact.get_cvesorders bypriority.sql_order, anORDER BYbuilt from the constantspriority()decides with, then by date and id as tie-breaks. The order stays in SQLite, so a listing of 50 is still a query for 50.cves_by_priorityon that expression. On the benchmark's 500 CVEs the full listing takes 1.0 ms, against 1.45 ms on main (date order) and 1.9 ms without the index. The listing filtered by product does not use it: ~1.7 ms, against 1.41 ms on main./api/cvesrows carrypriority,priority_reason,known_exploited,kev_ransomware,kev_date_addedandkev_due_date.statusis titled "Most urgent CVEs" and has a Priority column.test_priority_wiring.pynow holds the other side: the facts are stored, andget_cvesorders bysql_order, not by date.Tests (strict TDD)
tests/test_priority_stored.py, 10 tests:cves;sort_by_priorityand must come out identical. The edges are EPSS exactly at 0.1, EPSS 1.5, maturity E:P and E:U, ransomware "Unknown", CVSS 0.0 next to no score, and score ties. The same check runs on the per-product path and on a shortLIMIT;/api/cvesandstatus.Seen failing first (10/10 red). 15 of 16 mutants killed. The survivor removes the "scored" branch of the CASE, which is equivalent:
COALESCE(score, -1)already puts scored rows above unscored ones within the same rank. I kept the branch because it mirrorspriority()'s ranks. Full suite: 2210 passed; ruff and mypy clean.🤖 Generated with Claude Code