Interpolate Maven ${...} properties through one formats::maven helper: five copies drifted on recursion, undefined names and the length cap
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with the interpolation helpers in crates/socket-patch-core/src/formats/maven/mod.rs and the four call sites in maven_crawler.rs, maven_scope.rs, and vendor/jvm/maven_reactor.rs. Read the existing tests for those paths and maven_pom_equivalence_tests.rs before consolidating the lookup loop. Done means in-cap behavior stays unchanged and a doubling property chain is refused in both scope and reactor tests.
由索引模型根据 Issue 内容生成。
描述
[agent] Filed by the scheduled architecture audit (audit-core). Register: register.
Kind: refactor. Register ID: A30.
Problem
The ${name} substitution loop (find("${"), find('}'), lookup, push) is written five times. The copies have drifted:
| Copy | Recursive | Undefined name | Output length cap |
|---|---|---|---|
| maven_crawler::interpolate L738-L751 (settings.xml) | no | None |
none |
| formats::maven::interpolate / interpolate_once L329-L372 | up to MAX_INTERPOLATION rounds |
kept verbatim | MAX_INTERPOLATED_LEN |
| maven_scope::interpolate_at L491-L534 | depth-limited | None |
none |
| maven_reactor::interpolate_by L1002-L1021 | depth-limited | None |
none |
| maven_reactor::Reactor::interpolate_with L1689-L1710 | depth-limited | None |
none |
The last three are the same loop body, differing only in how they call the lookup:
while let Some(at) = rest.find("${") {
out.push_str(&rest[..at]);
let after = &rest[at + 2..];
let close = after.find('}')?;
let raw = lookup(&after[..close])?;
out.push_str(&interpolate_by(&raw, lookup, depth + 1)?);
rest = &after[close + 1..];
}
Only formats::maven caps the output length. The depth-limited recursive copies can still grow exponentially within the depth limit (a=${b}${b}, b=${c}${c}, …), which is the "billion laughs" case that cap exists for. This is from reading the code; I did not execute it.
Proposed change
- Add
formats::maven::interpolate_by(value, lookup: &dyn Fn(&str) -> Option<String>) -> Option<String>. It recurses withMAX_INTERPOLATIONas the depth limit and returnsNonepastMAX_INTERPOLATED_LEN. maven_scope,maven_reactor(both) andmaven_crawlerkeep their lookup closures and call it.maven_crawler's settings.xml use is non-recursive today. Maven itself interpolates settings.xml from env/system properties only, so recursion there is harmless, but keep a test that pins its current result.formats::maven::interpolate's keep-unresolved mode becomes a lookup that echoes${name}back, so it can share the loop too. If that changes its output, it can stay as the one separate wrapper.
Size
4 files, about −70 lines.
Acceptance criteria
- Behavior is unchanged for in-cap inputs. These must stay green: the existing
maven_scope,maven_reactorandformats::maveninterpolation tests, andmaven_pom_equivalence_tests.rs. - Add one test showing that a doubling property chain returns
None(refused) in the scope and reactor paths instead of growing pastMAX_INTERPOLATED_LEN.
- 主要语言
- Rust
- 星标
- 8
- 派生
- 2
- 平均合并
- 19 小时 12 分钟
- 30 天内合并 PR
- 709
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged arch-audit priority:p3 refactor
难度 2/5 1-3 小时 新手友好度 83/100
SocketDev/socket-patch#1860 ·
维护者通常 1 天内回复
-
agent:triaged arch-audit priority:p3 refactor
难度 2/5 1-3 小时 新手友好度 78/100
SocketDev/socket-patch#1838 ·
维护者通常 1 天内回复
-
Share one scoped env-var test guard: EnvGuard is copy-pasted 11 times across core unit and integration tests可能已有人在做 @mikolalysenko 今天认领。 未关闭agent:claimed agent:triaged arch-audit priority:p3 refactor
难度 4/5 3-5 天 新手友好度 55/100
SocketDev/socket-patch#1889 · 2 条评论 ·
维护者通常 1 天内回复
-
Memoize env-keyed subprocess probes through one helper: composer, python and ruby each define the same env key and drifted on when an answer is kept可能已有人在做 @mikolalysenko 今天认领。 未关闭agent:claimed agent:triaged arch-audit priority:p1 refactor
难度 4/5 1-2 天 新手友好度 25/100
SocketDev/socket-patch#1888 · 3 条评论 ·
维护者通常 1 天内回复
-
agent:needs-human agent:triaged arch-audit priority:p3 refactor
难度 4/5 3-5 天 新手友好度 38/100
SocketDev/socket-patch#1881 ·
维护者通常 1 天内回复
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
dekobon/big-code-analysis#1729 ·
维护者通常 1 天内回复
-
bug help wanted
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
akitaonrails/ai-memory#1888 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
peteonrails/voxtype#941 ·
维护者通常 4 天内回复
-
bug priority:medium triage:maintainable
难度 2/5 1-3 小时 新手友好度 82/100
ccusage/ccusage#2000 · 3 条评论 ·
维护者通常 1 天内回复