fix(m200-r1): 文档降到实测能撑的程度 + 守门收紧 core 声明内容(复审 P2-1 / P3-1)
复审 reviewer-presenterfix-r1 的 fix-then-merge 两条,逐条落地。
P2-1(a)「两档」措辞被本次提交自己作废 ⇒ 三处全改成三档:
* `crates/core/src/update/trust.rs` 模块文档(读者最先看到的那句,上次漏了)
* `crates/core/src/update/tests/support_sign.rs` 模块文档 + `TEST_SIGNING_SEED` 的文档
P2-1(b)「三者都进不了发布产物」被复证实测证伪(`cfg!()` 是运行时假分支,不是 `#[cfg]`
编译期剔除;无 feature 的 dev 与 --release 两档 core rlib 里公钥十六进制与 `test-only-key` 都在)
⇒ 降级到事实能撑的断言:「不会被 `keyring()` 并进信任表,正式构建永远不认这把测试钥」,
并明写「字节仍编在产物里」「字节级不在产物里未证、也未声称」「换 `#[cfg]` 是另一条结构性改动」。
没有换成 `#[cfg]`(那是复审建议另开的 mission)。
P3-1 守门对 core「自己的声明」只认形状 ⇒ 收紧为只许空数组:
`DECLARATION` 从 `^\s*update-test-key\s*=\s*\[` 改成 `^\s*update-test-key\s*=\s*\[\s*\]\s*$`,
并加一条自检向量(core 声明里偷偷带子 feature ⇒ 必须红)。`--self-test` 从 6 条变 7 条
(5 红 / 2 绿)+ 基线,`packaging/README.md` 的计数同步。
⚠ 一个自己踩出来的坑,已被既有守门抓住:收紧时我先在 `check_test_key_off.py` 里把那条更宽的
测试通道 feature 写成**字面量**(自检向量 + 文档表格),`check_test_source_off.py` 立刻红
(`packaging/**` 按字面扫,这次提交前它一直是绿的)。改法照该文件自己的声明办——用
`OTHER_FEATURE = "-".join(("update", "test", "source"))` 拼出来,源码里字面量为 0,
自检向量仍然构造出完整字符串并必须判红。
验证(均在最终树上):`cargo test --workspace --all-targets` 0、`cargo fmt --all --check` 0、
`check_test_key_off.py --self-test` 0(7 向量)/ 正式扫描 0、`check_test_source_off.py` 0、
`check_workflows_yaml.py` 0。
This commit is contained in:
1 parent
528f5706a0
commit
540b82e197
4 files changed
+36
-14
No files matched your search
@@ -14,12 +14,13 @@
|
||||
|
||||
| 允许出现的地方 | 形态 |
|
||||
|---|---|
|
||||
| `crates/core/Cargo.toml` | 只能是它自己的声明 `update-test-key = [` |
|
||||
| `crates/core/Cargo.toml` | 只能是它自己的声明,且必须是**空数组** `update-test-key = []`(写成带子 feature 的非空数组即红) |
|
||||
| `crates/presenter/Cargo.toml` | 只能出现在 `[dev-dependencies]` 段内 |
|
||||
| 本脚本 | 它必须写出这个 feature 名 |
|
||||
|
||||
其余任何地方(workflow、`packaging/` 的脚本、根 `Cargo.toml`、`.cargo/config*.toml`、presenter 的
|
||||
`[dependencies]`)提到它即红。`--self-test` 把这三类真实回归各注入一次,并断言合法写法不误杀。
|
||||
`[dependencies]`)提到它即红。`--self-test` 把这四类真实回归各注入一次(workflow / presenter 的
|
||||
`[dependencies]` / 根 `Cargo.toml` / core 声明里偷偷带子 feature),并断言合法写法不误杀。
|
||||
|
||||
python3 packaging/check_test_key_off.py
|
||||
python3 packaging/check_test_key_off.py --self-test
|
||||
@@ -65,7 +66,15 @@ GLOBS = (
|
||||
ALLOWED_DECLARATION = "crates/core/Cargo.toml"
|
||||
ALLOWED_DEV_DEPENDENCY = "crates/presenter/Cargo.toml"
|
||||
|
||||
DECLARATION = re.compile(rf"^\s*{re.escape(FEATURE)}\s*=\s*\[")
|
||||
#: 另一条(更宽的)测试通道 feature 的名字。**刻意拼出来**:`check_test_source_off.py` 按字面扫
|
||||
#: `packaging/**`,这里写全名会让那个守门红 —— 那是它的设计(宁可误杀也不放过),不是笔误。
|
||||
#: 本文件与它同源同一套手法,别“顺手”把它写成字面量。
|
||||
OTHER_FEATURE = "-".join(("update", "test", "source"))
|
||||
|
||||
#: core 只许**自己的声明**,而且必须是**空数组** `update-test-key = []`。
|
||||
#: 这里认**内容**、不只认形状:写成带子 feature 的非空数组(`["<另一条 feature>"]`)会让这个「窄口子」
|
||||
#: 顺手把「宽口子」(环境变量 + `DirSource` 那条测试通道)拉起来 —— 那正是本守门要防的逃逸。
|
||||
DECLARATION = re.compile(rf"^\s*{re.escape(FEATURE)}\s*=\s*\[\s*\]\s*$")
|
||||
SECTION = re.compile(r"^\s*\[([^\]]+)\]\s*$")
|
||||
|
||||
|
||||
@@ -184,6 +193,11 @@ VECTORS = [
|
||||
{"crates/core/Cargo.toml": "[features]\nupdate-test-key = []\n"},
|
||||
"green",
|
||||
),
|
||||
(
|
||||
"core 的声明里偷偷带子 feature(形状合法、内容非法)",
|
||||
{"crates/core/Cargo.toml": f'[features]\n{FEATURE} = ["{OTHER_FEATURE}"]\n'},
|
||||
"red",
|
||||
),
|
||||
("注释里提到它(合法)", {"packaging/y.py": "# 见 update-test-key 的说明\n"}, "green"),
|
||||
]
|
||||
|
||||
|
||||
Reference in new issue
Block a user