Skip to content

fix(cve): per-year TSVs sort CVE id lexicographically, so 5-digit ids (>=10000) are out of order #3

Description

@edwinjhlee

现象

x cve | head 永远停在 CVE-2026-9999,看不到 CVE-2026-10000 ~ CVE-2026-99999。

例如(按现在 per-year TSV 的顺序):

CVE-2026-9999    ← 显示的"最高"
CVE-2026-9998
...
CVE-2026-90616   ← 真实最高(5 位序号)
...
CVE-2026-10000
CVE-2026-09999

原因是 MITRE 自 ~2025 起开始发 5 位序号(NNNN >= 10000)的 CVE id,而我们的 save_year_files 用字符串字典序 sort(reverse=True)——'90616' < '9999',所以 9999 排在了 90616 上面。

复现

$ awk -F'\t' '{split($1,p,"-"); if(length(p[3])>4) c++} END{print c}' data/cve-2026.tsv
47517
# 2026 年 47,517 条 id 已经超过 4 位

$ awk -F'\t' '{split($1,p,"-"); print p[3]+0, $1}' data/cve-2026.tsv | sort -k1,1 -n | tail -3
90615 CVE-2026-90615
90616 CVE-2026-90616
# 真实最高是 90616;head 看到的"最高"是 9999

根因

.x-cmd/_cve_index.py:355 —— buckets[year].sort(reverse=True) 是字符串排序。需要按 NNNN 段当整数比较。

修复方案

  • _cve_index.py:save_year_files 把 buckets[year].sort(reverse=True) 换成按 (year, int(seq)) 元组数字排序倒序;
  • 触发一次 tsv.py --rebuild 让 28 个 per-year 文件就地重新排序(一次 ~2 分钟,无网络);
  • README「行序 —— 最新优先」段保留,因为排序语义没变(仍按 cve id 降序),只是补一句「按 NNNN 整数字段」。

影响

  • x cve | head / x cve fz 的「最新优先」承诺失效,用户看不到 2025+ 年的真正最新 CVE;
  • cve-*.tsv 文件字节序改变,所有 xz 资产需要重打包(CI 会自动检测 changed.txt 重传);
  • 不影响 schema、不影响 release asset 的下载 URL、不影响 x cve info 的查询路径。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions