fix(core): trust.rs 的 PinnedKey 交回 rustfmt 排版(多行字段)+ 自测锁住多行解析
v0.2.4 推 main 后 CI 的 fmt job 红:cargo fmt --all --check 退出码 1,唯一 diff 在 crates/core/src/update/trust.rs:60 —— PRODUCTION 里那条 PinnedKey 被写成单行。 * trust.rs:由 `cargo fmt --all` 直接生成(不是手写对齐)。git diff 只有这一处; 两个 PINNED-KEYS 标记行的字形与行位置未动;public_key_hex 与 HEAD 逐字比对 identical。 * sign_manifest.py --self-test:补一条多行(rustfmt)形态样例的解析断言。解析器本身无需改 (KID_RE 字段之间是 \s*,本来就跨行),但旧自测只喂单行样例 —— 变异重放(换成单行整行正则) 时旧自测全绿、新断言红,正是这次事故的形状。 验证(真实退出码):cargo fmt --all --check = 0;python packaging/sign_manifest.py --check-pinned-keyring --key <私钥路径> = 0;signing_ready_selftest.py = 0; signing_ready_wiring_selftest.py = 0;sign_manifest.py --self-test = 0; cargo test -p unlucky-core --lib update = 0(114 passed / 0 failed)。
This commit is contained in:
1 parent
38c568d6b7
commit
00965e19d2
2 files changed
+10
-1
No files matched your search
@@ -60,7 +60,10 @@ pub(crate) struct PinnedKey {
|
|||||||
/// (`packaging/sign_manifest.py --check-pinned-keyring` 按标记解析这一段,标记变了它就找不到表)。
|
/// (`packaging/sign_manifest.py --check-pinned-keyring` 按标记解析这一段,标记变了它就找不到表)。
|
||||||
pub(crate) const PRODUCTION: &[PinnedKey] = &[
|
pub(crate) const PRODUCTION: &[PinnedKey] = &[
|
||||||
// >>> PINNED-KEYS >>>
|
// >>> PINNED-KEYS >>>
|
||||||
PinnedKey { key_id: "ull-release", public_key_hex: "1c3687ecd656a29fda87a7afb56e07d2b9e223b62cf3a6f1a901fb499a97b122" },
|
PinnedKey {
|
||||||
|
key_id: "ull-release",
|
||||||
|
public_key_hex: "1c3687ecd656a29fda87a7afb56e07d2b9e223b62cf3a6f1a901fb499a97b122",
|
||||||
|
},
|
||||||
// <<< PINNED-KEYS <<<
|
// <<< PINNED-KEYS <<<
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,12 @@ def do_self_test() -> int:
|
|||||||
if pinned_keys(sample) != [("k1", "ab" * 32)]:
|
if pinned_keys(sample) != [("k1", "ab" * 32)]:
|
||||||
print("FAIL: pinned_keys() 没解析出示例条目", file=sys.stderr)
|
print("FAIL: pinned_keys() 没解析出示例条目", file=sys.stderr)
|
||||||
failures += 1
|
failures += 1
|
||||||
|
# 多行形态(M261):`trust.rs` 里那一条是 `cargo fmt` 生成的,字段一行一个 —— 靠 `KID_RE` 的 `\s*`
|
||||||
|
# 跨行命中。若解析器退化成按行匹配,一次 fmt 就会把整张信任表**静默**读成空表(= 全量客户端验签失败)。
|
||||||
|
multiline = f'{PIN_BEGIN}\n PinnedKey {{\n key_id: "k1",\n public_key_hex: "{"ab" * 32}",\n }},\n{PIN_END}'
|
||||||
|
if pinned_keys(multiline) != [("k1", "ab" * 32)]:
|
||||||
|
print("FAIL: pinned_keys() 没解析出多行(rustfmt)形态的条目", file=sys.stderr)
|
||||||
|
failures += 1
|
||||||
if pinned_keys(f"{PIN_BEGIN}\n{PIN_END}") != []:
|
if pinned_keys(f"{PIN_BEGIN}\n{PIN_END}") != []:
|
||||||
print("FAIL: pinned_keys() 在空表上应返回空", file=sys.stderr)
|
print("FAIL: pinned_keys() 在空表上应返回空", file=sys.stderr)
|
||||||
failures += 1
|
failures += 1
|
||||||
|
|||||||
Reference in new issue
Block a user