fix(migration): re-derive base_score from advisory_vulnerability_score#2536
Open
ctron wants to merge 7 commits into
Open
fix(migration): re-derive base_score from advisory_vulnerability_score#2536ctron wants to merge 7 commits into
ctron wants to merge 7 commits into
Conversation
Add CVE-2025-6965 as a test fixture and verify that its CVSS v4.0 score (High, 7.2) is correctly exposed through all vulnerability endpoints: detail, detail with ?scores=true, and list. Implements TC-5272 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend cvss_v4_score_visibility to simulate the post-migration state where advisory_vulnerability_score has valid CVSS scores but vulnerability.base_score is NULL. Re-running the data migration (m0002010_add_advisory_scores) repopulates advisory scores but does not backfill vulnerability.base_score, confirming the migration gap. Implements TC-5272 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a test that imports a 0.4.z database dump (with CVE-2025-6965 ingested), runs all pending migrations, and verifies that base_score preserves the correct CVSS v4.0 type. Currently fails because migration m0002170 blindly sets base_type='3.0' for all rows, even those with v4.0 or v2.0 scores. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…_score Migration m0002170 set base_type='3.0' for all vulnerability rows with a non-null base_severity, but the ingestor had been writing v2.0 and v4.0 scores to those columns since October 2025. Add a corrective migration that re-derives base_score, base_severity, and base_type from the authoritative advisory's entries in advisory_vulnerability_score, using the same "highest CVSS version, then highest score" logic as the Rust ingestor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rized rstest Add a database dump from the 0.3.z branch (with CVE-2025-6965 ingested) and merge the 0.3.z and 0.4.z migration tests into a single parameterized rstest. Both cases verify that base_score preserves the correct CVSS v4.0 type after migrating to current. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ions Ingest all 6 historical revisions of CVE-2025-6965 from the cvelistV5 repo in chronological order and verify the final base_score is correct. Confirms the CveLoader handles re-ingestion correctly — each update preserves the CVSS v4.0 type and score. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nown score Add a database dump from v0.2.19 (no base_score columns) to the migration test. This reproduces the actual TC-5272 bug: CVE-2025-6965 was ingested on 0.2.x before base_score existed, and after upgrading the score was never backfilled — resulting in NULL base_score ("Unknown" in the UI). Implements TC-5272 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Sorry @ctron, your pull request is larger than the review limit of 150000 diff characters
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2536 +/- ##
==========================================
+ Coverage 72.17% 72.20% +0.03%
==========================================
Files 465 466 +1
Lines 28702 28719 +17
Branches 28702 28719 +17
==========================================
+ Hits 20715 20736 +21
+ Misses 6812 6802 -10
- Partials 1175 1181 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
m0002270that re-derivesvulnerability.base_score,base_severity, andbase_typefromadvisory_vulnerability_scorebase_scorecolumns existed were never backfilled after upgradingm0002170hardcodedbase_type = '3.0'for all existing scores, even v4.0 and v2.0 onesextract_base_score/get_scorelogic)vectorStringwithout individual metric fieldsWorkaround
To fix existing data without deploying, run this SQL directly on the database:
Note: This only works if the data migration
m0002010_add_advisory_scoreshas been run andadvisory_vulnerability_scoreis populated. If that table is empty, the data migration must be run first (trustd db data m0002010_add_advisory_scores).Test plan
cvss_v4_score_visibility— verifies all endpoints return correct scores after fresh ingestioncvss_v4_score_after_cve_history— verifies re-ingestion of all 6 historical revisions preserves correct scorescvss_v4_score_after_migration::from_02z— reproduces TC-5272: CVE ingested on 0.2.x → NULL base_score after migration → fix migration backfills itcvss_v4_score_after_migration::from_03z— CVE ingested on 0.3.z → wrong base_type after migration → fix migration corrects itcvss_v4_score_after_migration::from_04z— CVE ingested on 0.4.z → wrong base_type after migration → fix migration corrects itbase_score_after_ingestion— existing parameterized test with new CVSS v4.0 case, all passImplements TC-5272
🤖 Generated with Claude Code