Repository navigation
fix(mutant): tool patch 支持配置槽补丁并对齐 config crate 的 blob 前缀 - #31
Merged
h3zh1 merged 2 commits intoOct 16, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
使用 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-configcrate 的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_BLOB_PREFIX(当前CFGv4B64),mutant 的 blob 校验与槽定位统一引用该常量,后续版本升级不再漂移。configcrate 的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 模板均验证通过