Skip to content

Reset CVE v5 rank state before each import#27

Merged
adulau merged 1 commit into
mainfrom
codex/ensure-zrank-reset-on-each-import
Mar 22, 2026
Merged

Reset CVE v5 rank state before each import#27
adulau merged 1 commit into
mainfrom
codex/ensure-zrank-reset-on-each-import

Conversation

@adulau

@adulau adulau commented Mar 22, 2026

Copy link
Copy Markdown
Member

Motivation

  • Ensure the rank:cpe / vendor-product ranking produced from CVE v5 NDJSON does not accumulate across repeated imports and starts from a clean state each run.
  • Centralize the rank-reset logic so it can be reused and tested instead of duplicating key deletion in the import script.
  • Provide an opt-out for users who intentionally want cumulative behavior.

Description

  • Add a reset_rank_state(rdb, missing_word_key) helper in lib/cpeimport/cvelistv5.py and export it via lib/cpeimport/__init__.py to delete rank:cpe, rank:vendor_product, and the configured missing-word set.
  • Update bin/import_cvelistv5.py to call reset_rank_state() by default before importing and add a --preserve-rank flag to keep previous behavior when requested.
  • Add a regression test test_reset_rank_state_clears_previous_import_data to tests/test_cvelistv5.py to verify the reset clears only the CVE v5 ranking state and does not remove unrelated w:<word> data.
  • Update README.md to document the new default behavior and the --preserve-rank opt-out.

Testing

  • Ran python -m unittest tests.test_cvelistv5 and the test suite passed (all tests OK).
  • Ran python -m unittest tests.test_nvd_json and the test suite passed (all tests OK).

Codex Task

@adulau adulau merged commit ed11125 into main Mar 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant