Global mode never finds yarn 1.0.x global packages: `yarn global dir` doesn't exist before yarn 1.1.0, and there's no fallback
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start in crates/socket-patch-core/src/crawlers/npm_crawler.rs at lines 514 and 1151, then review the existing global-mode tests and yarn-classic-matrix coverage. Reproduce the yarn 1.0.2 case from the issue and compare it with yarn 1.1.0. Done means supported yarn 1.0.x global packages are found or the scan warns instead of reporting a clean success, without regressing the existing matrix.
由索引模型根据 Issue 内容生成。
描述
[agent] Found by the scheduled Yarn classic (1.x) bug-hunt routine (ledger #304).
Summary
scan -g, scan -g --mode agent, get -g, rollback -g and vex -g find yarn's global packages only by running yarn global dir. That subcommand doesn't exist in yarn 1.0.0–1.0.2: it prints error Invalid subcommand. Try "add, bin, ls, list, remove, upgrade, upgrade-interactive" and exits 1. The lookup then returns None, nothing else probes yarn's global folder, and every package installed with yarn global add is silently left out. Every command exits 0 with status: success.
Yarn 1.1.0 added yarn global dir. I bisected through corepack: 1.0.2 exits 1, while 1.1.0, 1.2.1, 1.3.2, 1.4.0, 1.5.1 and 1.6.0 print the folder. The folder itself (~/.config/yarn/global, or /usr/local/share/.config/yarn/global for root, %LOCALAPPDATA%\Yarn\Data\global on Windows) hasn't moved between 1.0 and 1.1.
Impact
It's a silent miss. On a machine with yarn 1.0.x, scan -g reports no patchable yarn-global tools, and scan -g --mode agent exits 0 with applied: 0 while the global copy stays vulnerable. The routine's version range (and CI's yarn-classic-matrix, which starts at 1.0.2) treats 1.0.x as supported, and docs/ecosystems.md doesn't mention this limitation. Yarn 1.0.x is old (2017), so this is low priority, but the result is a false all-clear rather than a refusal.
Repro (Linux sandbox, main 2463257)
corepack [email protected] global add [email protected] # lands in /usr/local/share/.config/yarn/global/node_modules (root)
corepack [email protected] global dir # error Invalid subcommand … (exit 1)
# with `yarn` on PATH = yarn 1.0.2, mock patch API serving pkg:npm/[email protected]:
socket-patch scan -g $API --json # status success, packages [] <- miss
socket-patch scan -g --mode agent $API --json # status success, apply.applied 0, exit 0
head -1 /usr/local/share/.config/yarn/global/node_modules/is-number/index.js # still upstream
# same machine, same global folder, `yarn` = 1.1.0:
socket-patch scan -g $API --json # packages ["pkg:npm/[email protected]"] <- found
Expected vs actual
- Expected: CLI_CONTRACT.md documents
--globalas "Operate on globally-installed packages", with--global-prefixdefaulting to "(auto)". The global-mode checklist (ledger #304) requiresscan -gto find every globally installed package, with none missing. When yarn is on PATH butyarn global dirfails, socket-patch should fall back to yarn's default global folder (oryarn global bin's sibling, or.yarnrcglobal-folder). Failing that, it should warn that yarn's global folder couldn't be determined, rather than report a clean scan. - Actual: yarn-global packages are invisible, with exit 0.
OS × yarn matrix (probe run, plus the Linux sandbox)
| OS | yarn 1.0.2 | yarn 1.10.1 | yarn 1.22.22 |
|---|---|---|---|
| Linux (sandbox + ubuntu-latest) | miss (scan_report, agent_apply, vex fail) |
pass | pass |
| macOS (macos-latest) | miss | pass | pass |
| Windows (windows-latest) | miss (also #434) | miss, see #434 | miss, see #434 |
On Windows every yarn version misses, for a separate reason: the bare yarn spawn never resolves yarn.cmd, which is tracked in #434. 1.0.x would still miss after that fix.
Suspect code
crates/socket-patch-core/src/crawlers/npm_crawler.rs:514:get_yarn_global_prefix_withruns onlyyarn global dir.None(non-zero exit) is final.crates/socket-patch-core/src/crawlers/npm_crawler.rs:1151:get_global_node_modules_pathshas no yarn fallback. The only fallbacks are the macOS-only npm ones.
Probe run: https://github.com/SocketDev/socket-patch/actions/runs/36827174726 (jobs global * yarn 1.0.2 print global dir: yarn global v1.0.2 … /node_modules and scan_report … result=FAIL).
- 主要语言
- Rust
- 星标
- 8
- 派生
- 0
- 平均合并
- 19 小时 44 分钟
- 30 天内合并 PR
- 450
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged bug bughunt pm:npm priority:p3
难度 2/5 1-3 小时 新手友好度 75/100
SocketDev/socket-patch#1072 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:bundler priority:p1
难度 2/5 1-3 小时 新手友好度 85/100
SocketDev/socket-patch#896 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
难度 2/5 1-3 小时 新手友好度 73/100
SocketDev/socket-patch#783 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:cargo priority:p2
难度 2/5 1-3 小时 新手友好度 84/100
SocketDev/socket-patch#651 · 3 条评论 ·
维护者通常 1 天内回复
-
CI perf: e2e-build-windows — full Windows test build is the merge-queue critical path in 27/30 runs (~2.5 min off every merge)可能已有人在做 @mikolalysenko 今天认领。 未关闭agent:claimed agent:triaged ci-perf priority:p3
难度 3/5 1-2 天 新手友好度 30/100
SocketDev/socket-patch#1385 · 2 条评论 ·
维护者通常 1 天内回复
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
swc-project/swc#12516 ·
维护者通常 1 天内回复
-
mls-rs-crypto-awslc: exact aws-lc-rs =1.16.3 pin blocks rustls security update可能已有人在做 @muscariello 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
-
[work-item] adam-adae-worsening-emergence: conform spec.yaml to the specification style contract (REQ-1280)可能已有人在做 @muse-yamaa-bot 今天认领。 未关闭work-item
难度 1/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 63/100
metasequoiaime/msime#7328 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
eclipse-opensovd/classic-diagnostic-adapter#616 ·
维护者通常 2 天内回复