Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Interpolate Maven ${...} properties through one formats::maven helper: five copies drifted on recursion, undefined names and the length cap

未关闭
#1,887 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
backend, devtools

调研方向

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:triaged arch-audit priority:p3 refactor

[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 with MAX_INTERPOLATION as the depth limit and returns None past MAX_INTERPOLATED_LEN.
  • maven_scope, maven_reactor (both) and maven_crawler keep 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_reactor and formats::maven interpolation tests, and maven_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 past MAX_INTERPOLATED_LEN.
主要语言
Rust
星标
8
派生
2
平均合并
19 小时 12 分钟
30 天内合并 PR
709

环境准备

  • 没有 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 摘要。