Composer crawler ignores a vendor-dir set in the global Composer config, so scan -g and agent scans report "No packages found" and leave installs unpatched
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start in crates/socket-patch-core/src/crawlers/composer_crawler.rs, reading get_vendor_paths at lines 52-64 and resolve_local_vendor_dir at lines 473-492. Reproduce the global and local cases from the issue with Composer and the listed socket-patch scan commands, then verify scans discover packages installed through global, project, and COMPOSER_HOME configuration. Done means configured vendor directories are found and no longer produce empty successful scans.
由索引模型根據 Issue 內容生成。
描述
[agent] Found by the scheduled Composer bug-hunt routine (ledger #321).
Summary
Composer resolves vendor-dir through its config cascade: COMPOSER_VENDOR_DIR, then the project's composer.json config.vendor-dir, then the user-level $COMPOSER_HOME/config.json. The socket-patch Composer crawler follows only part of that cascade, so real installs go undiscovered:
- Global (
-g):get_vendor_pathshardcodes$COMPOSER_HOME/vendor(crates/socket-patch-core/src/crawlers/composer_crawler.rs:52-64). If the global project setsconfig.vendor-dir(composer global config vendor-dir deps, or"config":{"vendor-dir":"deps"}in$COMPOSER_HOME/composer.json), orCOMPOSER_VENDOR_DIRis exported,composer global requireinstalls to$COMPOSER_HOME/deps.scan -gthen finds 0 packages, andscan -g --mode agentprintsNo global packages found.with exit 0. - Local (agent mode):
resolve_local_vendor_dir(composer_crawler.rs:473-492) readsCOMPOSER_VENDOR_DIRand the projectcomposer.json, but not the user-level$COMPOSER_HOME/config.json. Aftercomposer config -g vendor-dir lib, every project'scomposer installwrites tolib/, andsocket-patch scan --mode agentreportsNo composer packages found.(exit 0) while the package stays unpatched.
In both cases the failure is silent, with exit 0 and nothing patched or attested.
Repro (Linux; Composer 2.8.12, mock patch API, local path-repo package acme/[email protected])
# 1. global
export COMPOSER_HOME=$PWD/ch
composer global config repositories.local '{"type":"path","url":"/abs/pkgs/tool","options":{"symlink":false}}'
composer global config vendor-dir deps
composer global require acme/tool:1.0.0 # -> $COMPOSER_HOME/deps/acme/tool
socket-patch scan -g --json --ecosystems composer # packagesWithPatches 0, scannedPackages 0
socket-patch scan -g --mode agent --yes --ecosystems composer # "No global packages found." exit 0
socket-patch scan --global-prefix "$COMPOSER_HOME/deps" --json --ecosystems composer # finds 1 (workaround)
# 2. local, user-level config
composer config -g vendor-dir lib # writes $COMPOSER_HOME/config.json
composer install # -> ./lib/acme/tool
socket-patch scan --mode agent --yes --ecosystems composer # "No composer packages found."
COMPOSER_VENDOR_DIR=gdeps composer global require … followed by COMPOSER_VENDOR_DIR=gdeps socket-patch scan -g also finds nothing. Composer resolves the variable against the global home, while the global branch never reads it.
Expected vs actual
- Expected: CLI_CONTRACT.md
--global: "Operate on globally-installed packages". The crawler's local-mode doc promisesCOMPOSER_VENDOR_DIR/config.vendor-dirsupport, and Composer applies the same cascade (includingconfig.json) to the global project and to every local one. The maintainer requirement for-gis that none may be missing. - Actual: packages installed under a configured vendor-dir are invisible, and the commands exit 0.
OS × version
| OS | Composer | global vendor-dir → scan -g / apply -g |
user config.json vendor-dir → local agent scan |
|---|---|---|---|
| Linux (local) | 1.10.28, 2.2.30, 2.8.12, 2.10.3 (PHP 8.3) | fail (each run twice) | fail (2.8.12, twice) |
| ubuntu-latest | 1.10.28, 2.2.30, 2.10.3 | fail | untested |
| macos-latest | 1.10.28, 2.2.30, 2.10.3 | fail | untested |
| windows-latest | 1.10.28, 2.2.30, 2.10.3 | fail | untested |
The default vendor/ layout passes everywhere except Windows, where default-home discovery is broken separately (#438).
Probe runs: https://github.com/SocketDev/socket-patch/actions/runs/36823671080 and https://github.com/SocketDev/socket-patch/actions/runs/36827949605
First bad version
Not a regression. It reproduces identically with the v4.0.0 release binary (both cases: 0 scanned).
Suspect code
crates/socket-patch-core/src/crawlers/composer_crawler.rs:52-64(global:composer_home.join("vendor"))crates/socket-patch-core/src/crawlers/composer_crawler.rs:473-492(local: no$COMPOSER_HOME/config.jsonlayer)
- 主要語言
- Rust
- 星號
- 8
- 分支
- 0
- 平均合併
- 1 天 31 分鐘
- 30 天內合併 PR
- 151
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
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:pipenv priority:p1
難度 2/5 1-3 小時 新手友好度 83/100
SocketDev/socket-patch#744 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:cargo priority:p2
難度 2/5 1-3 小時 新手友好度 84/100
SocketDev/socket-patch#651 · 3 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:composer priority:p2
難度 2/5 1-3 小時 新手友好度 90/100
SocketDev/socket-patch#515 · 1 則留言 ·
維護者通常 1 天內回覆
-
A report-only `scan -g` tells you to run `socket-patch scan --mode agent [PATHS]` without `-g`, so following the hint scans the cwd project instead of the global install可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged bug bughunt pm:npm priority:p1
難度 2/5 1-3 小時 新手友好度 82/100
SocketDev/socket-patch#464 · 1 則留言 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 78/100
zcashlabs/thus-spoke-zakura#153 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 79/100
topgrade-rs/topgrade#2395 ·
維護者通常 1 天內回覆
-
app bug windows-os
難度 2/5 1-3 小時 新手友好度 67/100
維護者通常 1 天內回覆
-
editor good first issue
難度 2/5 1-3 小時 新手友好度 65/100
funnyboy-roks/inq#54 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆