VEX gemspec product detection reads commented-out `# spec.name =` / `# spec.version =` lines, so the document names the wrong product or version
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
gemspec 解析器是 parse_gemspec,位於 crates/socket-patch-core/src/vex/product.rs 中(約第363-380行);probe 9 記錄在 vex.rs 第66行左右。先閱讀 literal 閉包,然後將 issue 中的兩個重現 gemspec 透過它執行,確認被註解的 # spec.version = 和 # spec.name = 行能夠被比對。完成標準是兩個檔案都輸出 pkg:gem/acme 且捨棄計算出的版本,並有回歸測試涵蓋被註解行的情況。
由索引模型根據 Issue 內容生成。
描述
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
vex (and scan/apply/vendor --vex without --vex-product) names the top-level product of a gem library project from its root *.gemspec (parse_gemspec, probe 9). The parser takes the first line whose =-left side ends in .name / .version and whose right side starts with a quote. It never skips Ruby comments, so a commented-out assignment wins over the live one:
# spec.version = "0.0.1"abovespec.version = Acme::VERSION→ productpkg:gem/[email protected](the real version is 2.3.4; a computed version should be dropped, givingpkg:gem/acme).# spec.name = "acme-legacy"abovespec.name = "acme"→ productpkg:gem/acme-legacy.
No warning is printed. Ruby (Gem::Specification.load) gives acme-2.3.4 for both files.
Impact
The OpenVEX document's products[].@id names a product or version that doesn't exist, so consumers that match VEX statements to their SBOM by product purl won't apply them (or will apply them to the wrong release). The run reports success. Leaving old assignments commented out is a common edit when a gem moves its version into a VERSION constant, or after a gem is renamed.
Repro (Linux, Ruby 3.3.6, Bundler 2.5.22 / 4.0.18; main e76cb9b)
mkdir -p acme/lib/acme && cd acme
echo 'module Acme; VERSION = "2.3.4"; end' > lib/acme/version.rb
cat > acme.gemspec <<'E'
require_relative "lib/acme/version"
Gem::Specification.new do |spec|
spec.name = "acme"
# spec.version = "0.0.1" # pinned before the VERSION constant existed
spec.version = Acme::VERSION
spec.authors = ["x"]
spec.summary = "x"
spec.files = []
spec.add_dependency "colorize", "0.8.1"
end
E
printf 'source "https://rubygems.org"\ngemspec\n' > Gemfile
bundle install
# any applied gem patch in .socket/manifest.json (hand-written [email protected] manifest + `apply --offline` here)
socket-patch apply --offline
socket-patch vex | grep '"@id": "pkg:gem/acme'
# "@id": "pkg:gem/[email protected]"
ruby -e 'puts Gem::Specification.load("acme.gemspec").full_name'
# acme-2.3.4
The name variant: put # spec.name = "acme-legacy" above Gem::Specification.new (and drop the commented version). vex then gives "@id": "pkg:gem/acme-legacy". Each shape reproduced twice.
Expected vs actual
- Expected:
parse_gemspec's own doc says the product comes "from literal<spec>.name = "…"/<spec>.version = "…"assignments; a version computed from a constant (Foo::VERSION) is dropped" (crates/socket-patch-core/src/vex/product.rs:363-366). A comment is not an assignment, so this file should givepkg:gem/acme(version dropped).vex.rs:66documents probe 9 aspkg:gem/<name>[@<version>]. - Actual:
pkg:gem/[email protected]/pkg:gem/acme-legacy.
Matrix
| OS | Ruby / Bundler | Commented version |
Commented name |
|---|---|---|---|
| Linux (sandbox) | 3.3.6 / 2.5.22 | reproduces (×2) | reproduces (×2) |
The parser is OS- and Bundler-independent (pure text), so macOS / Windows aren't probed.
Suspect code
crates/socket-patch-core/src/vex/product.rs:367-380: the literal closure trims the line and checks lhs.ends_with(".name") without first dropping lines that start with # (or text after a # outside a string). =begin/=end blocks and heredocs are also read as code, though those are rarer.
First bad version: not bisected (the sandbox clone is shallow). parse_gemspec has had this shape since gemspec detection was added.
- 主要語言
- Rust
- 星號
- 8
- 分支
- 1
- 平均合併
- 16 小時 35 分鐘
- 30 天內合併 PR
- 574
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged bug bughunt pm:poetry priority:p1
難度 2/5 1-3 小時 新手友好度 80/100
SocketDev/socket-patch#1547 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:npm priority:p3 ux
難度 2/5 1-3 小時 新手友好度 75/100
SocketDev/socket-patch#1072 · 2 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
難度 2/5 1-3 小時 新手友好度 73/100
SocketDev/socket-patch#783 · 1 則留言 ·
維護者通常 1 天內回覆
-
Vendored cargo warns cargo_multi_version_old_cargo ("declares no rust-version") when the root package inherits rust-version from [workspace.package]可能已有人在做 @mikolalysenko 於 3 天前認領。 未關閉agent:triaged bug bughunt pm:cargo priority:p2
難度 2/5 1-3 小時 新手友好度 84/100
SocketDev/socket-patch#651 · 3 則留言 ·
維護者通常 1 天內回覆
-
bug bughunt pm:npm
難度 3/5 半天 新手友好度 62/100
SocketDev/socket-patch#1576 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
dependencies effort:low flow:chore rust
難度 2/5 1-3 小時 新手友好度 64/100
jaroslawherod/micold-ai-ide#875 ·
維護者通常 1 天內回覆
-
priority: low
難度 2/5 1-3 小時 新手友好度 65/100
storytold/photocraft#6286 · 1 則留言 ·
維護者通常 1 天內回覆
-
Four problem loader browser tests fail on Windows可能已有人在做 @Patriciaath999 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
Kazakh (kk_KZ) and Georgian (ka_GE) system locales get English instead of the shipped translations未關閉bug
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆