Serialize patch vulnerabilities through one helper; get's selectionRequired options[] are unsorted and drop description

未關閉
#1,836 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
58/100
Issue 類型
重構
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
rust
領域
cli

研究方向

Start with crates/socket-patch-cli/src/commands/agent_download.rs, list.rs, get.rs, and json_envelope.rs; compare the three vulnerability serializers and inspect select_json_mode_multi_free_options_serialize_vulnerabilities in get.rs. Run that test, then update it to assert that options contain vulnerabilities sorted by id with descriptions; confirm the other JSON outputs stay unchanged except for any deliberate severity field addition.

由索引模型根據 Issue 內容生成。

描述

agent:triaged arch-audit priority:p3 refactor

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

Kind: refactor (with a small output fix). Register ID: T02.

Problem

The per-vulnerability JSON object {id, cves, severity, summary, description} is built by hand in three places, and the copies have drifted:

  • agent_download::patch_event_metadata L119-L141 includes description and sorts by id. Its comment notes that "HashMap iteration is otherwise nondeterministic and consumers diff this output".
  • list.rs L172-L192 builds the same shape from a PatchRecord, sorted and with description, but it omits the top-level severity that patch_event_metadata emits.
  • get.rs L767-L790, the selectionRequired options[], iterates p.vulnerabilities (a HashMap) unsorted and omits description.

So get --json <CVE> with several free options lists each option's vulnerabilities in a different order from run to run. The test that claims to cover this, select_json_mode_multi_free_options_serialize_vulnerabilities (get.rs L4898), only asserts Err(1), so the drift went unnoticed.

Proposed change

  • Add one #[derive(Serialize)] vulnerability view, or a single vuln_json(id, &v) helper, in json_envelope.rs. It returns the list sorted by id.
  • Use it from all three sites.
  • Decide in the PR whether list gains the top-level severity, and say so in the PR description.

Size

3 to 4 files. About −40 / +30 lines.

Acceptance criteria

  • scan/get event details and list --json are byte-identical before and after, apart from any field the PR deliberately adds.
  • get's options[].vulnerabilities is sorted by id and carries description.
  • The fake test above captures the envelope and asserts the sorted options[].vulnerabilities.
主要語言
Rust
星號
9
分支
2
平均合併
20 小時 20 分鐘
30 天內合併 PR
659

環境準備

  • 沒有 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 摘要。