scan --package that matches nothing says to run the package manager's install

未關閉 適合新手
#2,296 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

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

研究方向

從 crates/socket-patch-cli/src/commands/scan/render.rs 中的 no_packages_message,以及它在 crates/socket-patch-cli/src/commands/scan/mod.rs 中的呼叫位置開始;追蹤套件篩選器和 socket.yml 允許清單如何產生空結果。擴充 no_packages_message_names_the_filter,並將 CLI 案例加入 scan render 測試套件。完成條件是兩個路徑都指出導致沒有剩餘套件的套件篩選器,而且現有的篩選器文字仍能通過測試。

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

描述

agent:triaged arch-audit bug priority:p3

[agent] Found by the architecture refactor routine on main at cfc870f. Kind: a class of wrong message fixed for two filters and still live for the third.

Problem

scan --package <spec> (or SOCKET_SCAN_PACKAGES) whose spec matches no installed package ends with:

No packages found. Run your package manager's install first.

The packages are installed. The spec is what matched nothing: a typo, or a version that is not the installed one. The message sends the user to reinstall, and nothing in the output names the flag. With the value in an environment variable of a CI job, the scan patches nothing, exits 0 and gives this as the reason.

The other two crawl filters name themselves. no_packages_message (crates/socket-patch-cli/src/commands/scan/render.rs, line 111) says so in its doc comment: "naming the filter that emptied it when there was one (--ecosystems, PATH scoping) instead of a generic "install first" hint".

Evidence on main

A project with four packages installed under node_modules (lodash 4.17.20 among them), binary built from cfc870f:

$ socket-patch scan --mode agent --dry-run --package lodahs
No packages found. Run your package manager's install first.
(exit 0)

$ socket-patch scan --mode agent --dry-run --package pkg:npm/[email protected]
No packages found. Run your package manager's install first.
(exit 0)

$ SOCKET_SCAN_PACKAGES=lodahs socket-patch scan --mode agent --dry-run
No packages found. Run your package manager's install first.
(exit 0)

$ socket-patch scan --dry-run --package lodahs          # hosted mode, the default
No packages found. Run your package manager's install first.
(exit 0)

The same project, emptied by the other two filters:

$ socket-patch scan --mode agent --dry-run --ecosystems pypi
No pypi packages found.
(exit 0)

$ socket-patch scan --mode agent --dry-run nosuchdir
No installed packages found under the given path: nosuchdir.
(exit 0)

A socket.yml allowlist that matches nothing prints the same first line, with the policy line after it:

$ cat socket.yml
version: 2
patches:
  packages: [lodahs]

$ socket-patch scan --mode agent --dry-run
No packages found. Run your package manager's install first.

Policy (socket.yml): 4 skipped by filters, 0 patched packages held.
(exit 0)

Cause and history

The call site (crates/socket-patch-cli/src/commands/scan/mod.rs, line 3202) passes the function --global, --ecosystems and the PATHs, and not args.packages.

  • #248 (2026-09-23) gave the function its filter-aware wording for --ecosystems and PATHs.
  • #277 (2026-10-01) added --package and did not extend it.
  • #2126 (for #2125) fixed another cause of the same sentence: an agent scan from a monorepo root that skipped the projects below it.

Planned fix

  • Pass the --package specs to no_packages_message, and say which filter left nothing when the crawl itself found packages: for example No installed package matches --package lodahs.
  • Use the same wording when the socket.yml allowlist (patches.packages) is what left nothing, so the first line agrees with the policy line under it.
  • Extend no_packages_message_names_the_filter and add one CLI case to the scan render suite.

Human wording only: no JSON shape, flag, default or exit code changes. CLI_CONTRACT.md does not quote these sentences.

Not checked: get, which has the same sentence at commands/get.rs line 4921.


Generated by Claude Code

主要語言
Rust
星號
9
分支
2
平均合併
1 天 8 小時
30 天內合併 PR
313

環境準備

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