Decide: should socket.yml refuse a bare package name with a version ([email protected]), as the selection filter does?

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

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

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

研究方向

Read CLI_CONTRACT.md and the validation for socket.yml and the selection filter to compare their handling of versioned bare package names. The issue presents three options and recommends refusing these entries in both patches.ignorePackages and patches.packages; a maintainer decision is needed before implementation. Done means the chosen behavior is applied consistently and documented.

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

描述

agent:needs-human agent:triaged arch-audit priority:p3

[agent] A decision for a maintainer, from the architecture refactor routine. Found on main at cfc870f while running the socket.yml patch policy. Related: #2294 (the same validator).

The question

Should socket.yml refuse a bare package name written with a version ([email protected]) in patches.ignorePackages and patches.packages, as the selection filter does?

What happens today

A bare name is compared with package names whole, so [email protected] can never match. In a denylist that is a deny that does nothing, with no warning:

$ cat socket.yml
version: 2
patches:
  ignorePackages:
    - [email protected]

$ socket-patch scan --mode agent
Applied 6 patches.
  CRITICAL  [email protected]     CVE-2026-0001
  …
(exit 0)

policy.filtered[] has no entry for lodash, warnings[] has nothing about the spec, and node_modules/lodash/index.js holds the patched content afterwards. In patches.packages the same entry selects nothing, which at least fails closed.

The selection filter refuses the same entry:

$ socket-patch scan --mode agent --dry-run --selection-filter filter.json
Error: selection filter filter.json: skip.packages[0]: a bare name takes no version; write a purl (`pkg:npm/[email protected]`): `[email protected]`
(exit 2)

Why the contract does not settle it

CLI_CONTRACT.md lists what is invalid in socket.yml ("Invalid: empty, or pkg: without a type and a name"), and says of the selection filter that it also refuses an entry "that could never match: a bare package name with a version". So today's behavior is the documented one in both places. The same section says "Because the file only narrows, a file that cannot be honored never means "no policy"", which is the case for refusing it.

Refusing it makes a socket.yml that is accepted today fail every scan with socket_yml_invalid (exit 1) until the entry is rewritten as a purl.

Options

  1. Refuse it in socket.yml with the selection filter's message. Fail closed, one rule in both files. A file that holds such an entry today starts failing scans.
  2. Warn and continue: a run-level warning that the entry can never match (beside socket_yml_ignored_value). No scan starts failing; the deny still does nothing until someone reads the warning.
  3. Leave it, and say in docs/configuration.md that a bare name takes no version.

The routine recommends option 1 for ignorePackages and packages alike: a deny that silently does nothing is the outcome the validation section exists to prevent.

scan --package [email protected] has the same reading (it matches nothing); #2296 covers what that run prints.


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 摘要。