Render a patch's vulnerability labels through one ui helper: scan, get and list each write the CVE-else-advisory rule, and their order, dedup and severity case drifted

未关闭
#1,880 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
cli

调研方向

Read ui/mod.rs and the referenced helpers in scan/render.rs, get.rs, and list.rs to trace the current label, ordering, deduplication, and severity behavior. Update the render byte tests in scan/render.rs and tests/cli/list_render.rs, and add a unit test for a CVE shared by two advisories. Done means all three commands use the shared UI helpers and the acceptance criteria pass.

由索引模型根据 Issue 内容生成。

描述

agent:triaged arch-audit priority:p3 refactor

[agent] Filed by the scheduled architecture audit (audit-cli-tests). Register: register comment.

Kind: refactor. Register ID: T28 (its JSON sibling is T02, #1836; its severity sibling is T10).

Problem

The human label of a vulnerability follows one rule: its CVE ids sorted, otherwise the advisory id. That rule is written four times:

  • scan: scan/render.rs vuln_label L385-L393,`` sorted worst-severity-first by sorted_vulns L371-L381;
  • get: get.rs L372-L382, the same body;
  • get again: vuln_labels L222-L236, which flattens and dedups;
  • list: list.rs L284-L288, which prints the advisory id with its CVEs in parentheses, unsorted, and sanitized.

The copies have drifted (verified by reading):

  • Order. scan orders the Fixes: list by severity; get orders it by label.
  • Dedup. scan doesn't dedup, so a CVE shared by two advisories prints twice; get dedups.
  • Severity label. get prints it uppercased (get.rs L289). scan's preview prints the raw API label through ui::severity, which passes unknown labels through unchanged. scan's policy line prints core's canonical severity_name, so "medium" appears where the API said "moderate" (policy.rs L752).
  • Sanitizing. Only list filters the API text (T23).

Proposed change

  • Add ui::vuln_labels(&HashMap<String, VulnerabilityResponse>) -> Vec<String>: CVEs else the id, deduped, in one documented order.
  • Add one ui::severity_label(&str) that uses core's severity_name.
  • scan, get and list call these helpers. Delete render::vuln_label/sorted_vulns, get's two copies and list's inline format.

Size

4 files (ui/mod.rs, scan/render.rs, get.rs, list.rs). Roughly −50 / +25.

Acceptance criteria

  • The render byte tests in scan/render.rs and tests/cli/list_render.rs are updated deliberately, once, to the chosen order and case.
  • A new unit test shows a CVE shared by two advisories printed once.
  • No CLI file keeps its own CVE-else-id closure.
主要语言
Rust
星标
8
派生
2
平均合并
18 小时 47 分钟
30 天内合并 PR
637

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SocketDev/socket-patch 的其他 Issue

查看 SocketDev/socket-patch 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。