Skip to content

fix(mutant): tool patch 支持配置槽补丁并对齐 config crate 的 blob 前缀 - #31

Merged
h3zh1 merged 2 commits into
chainreactors:masterfrom
dust-life:fix/tool-patch-config-blob
Oct 16, 2026
Merged

h3zh1 merged 2 commits into
chainreactors:masterfrom
dust-life:fix/tool-patch-config-blob

Conversation

@dust-life

Copy link
Copy Markdown
Contributor

问题

使用 malefic-mutant 对 --patch-mode 模板做配置槽补丁时发现两层断裂,导致该链路整体不可用:

1. 子命令语义断裂

tool patch 名字上像是给模板打配置,实际只能做 NAME/KEY/SERVER 字段补丁(仅认 -f);真正的配置槽补丁藏在 tool patch-config -f,两个子命令名字相近但参数形状完全不同。此外 patch-config 只认 -f/--file,没有更常见的 -i、--from-implant、--blob 等入口。

2. blob 前缀校验与 config crate 漂移(客观 bug)

malefic-mutant 在 main.rs 与 tool/patch.rs 硬编码校验 CFGv3B64 前缀,但 malefic-config crate 的 runtime.rs 内嵌槽与 encode_runtime_config 产出均已升级为 CFGv4B64——mutant 会拒绝自己生态生成的配置 blob。

自包含复现(不依赖任何外部项目):用 config crate 当前版本生成一份 runtime config blob,对任一 --patch-mode 模板执行配置槽补丁,校验阶段即被 CFGv3B64 硬编码拒绝。

修法

  • tool patch:-i/--input 作为 -f/--file 的 visible alias;新增 -c/--config、--from-implant、--blob 配置源参数。带配置源时走配置槽补丁(与 patch-config 共用提取出的 patch_runtime_config_blob()),不带时保持原 NAME/KEY/SERVER 字段补丁语义,混用明确报错。tool patch-config 行为不变。
  • 前缀校验不再硬编码:config crate 导出 CONFIG_BLOB_PREFIX(当前 CFGv4B64),mutant 的 blob 校验与槽定位统一引用该常量,后续版本升级不再漂移。
  • 附带修复:config crate 的 sample_config 缺 max_packet_length 字段导致 encoder-gated 测试模块无法编译,补上后 round_trip_encoding 与 rejects_bad_prefix 恢复可跑。

验证

  • cargo check / cargo test / cargo build --release 全过(encoder round-trip 测试 2 passed)
  • 手工端到端:tool patch -i <模板> --from-implant <yaml> -o <out> 成功,槽内容为 CFGv4B64 + base64;对同一输入重打结果确定;与 patch-config 产物逐字节一致;linux 与 windows PE 模板均验证通过

0x00 added 2 commits October 15, 2026 10:46
…crate blob prefix

tool patch now accepts -i/--input (alias of -f/--file) plus the config
blob sources -c/--config, --from-implant and --blob, routing to the
runtime config blob patcher; without them it keeps the NAME/KEY/SERVER
field patch behavior. tool patch-config is unchanged and shares the
same implementation.

The blob prefix is no longer hardcoded as CFGv3B64 in malefic-mutant:
the config crate exports CONFIG_BLOB_PREFIX (currently CFGv4B64) and
both blob validation and slot location follow it, so the patcher stays
in sync with the prefix embedded by ConfigBlobText.
The encoder-gated test module no longer compiled after RuntimeConfig
gained max_packet_length; with the field pinned the round_trip_encoding
and rejects_bad_prefix tests build and pass again.
@h3zh1
h3zh1 merged commit 30b02f8 into chainreactors:master Oct 16, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants