Files
ViewDesignEngine/tests/plugin/index_revocation_smoke.cmake
hm 8fa6dcec54
Build & Test / build-and-test (push) Canceled after 0s
VDE Build & Test / build-and-test (push) Canceled after 0s
Build & Test / python-bindings (push) Canceled after 0s
feat(P3-12b/13b/12c): 独立 vde-plugin-sdk 包 + 索引吊销强制 + 发布者指南/CI 模板(1.0.78)
### P3-12b 独立 vde-plugin-sdk 包
- 新增 vde-plugin-sdk CMake 包(纯 C ABI 头 vde_plugin_api.h、INTERFACE vde::plugin-sdk、组件安装、find_package);
- 独立纯 C consumer + CTest VDE_PluginSdkConsumerSmoke;VDE_INSTALL=OFF 不生成;

### P3-13b 索引吊销强制 --revoked-keys
- --verify-index/--install/--upgrade 支持吊销列表(行/JSON),签名 key_id 命中 → 退出 3;
- manifest 级吊销语义保留;--pubkey 文件路径支持;CTest VDE_PluginToolIndexRevocation;

### P3-12c 发布者指南 + CI 模板
- docs/guides/plugin-publishing.md、plugin-ci-template.md(OS×ABI 1.0–1.3 矩阵/签名/负例门禁);
- docs/index 导航、roadmap P3-12/P3-13 勾选与状态快照更新;

### 验证与工程
- 收录报告 73(1.0.77 独立验证 PASS:7558 注册/7463 执行/0 failed、assembly_feature consumer、kernel-only 0 undefined、warning 基线);
- 版本 1.0.78;全量构建 0 error(353 targets);全量 ctest 7560 注册、7465/7465 PASS(0 failed,25 skipped,274.53s);
- roadmap 状态快照(1.0.78):内部计划完成,外部依赖/可选后续列明。
2026-10-29 11:08:41 +08:00

90 lines
4.9 KiB
CMake

# P3-13b:插件仓库索引签名 key_id 吊销强制(CTest 脚本)
#
# 覆盖:本地签名索引 + --revoked-keys(行格式/JSON 格式)→ verify-index/install/upgrade
# 拒绝已吊销 key_id 且诊断含 revoked;不同 key 不受影响;吊销文件格式错误明确诊断。
#
# 调用(tests/plugin/CMakeLists.txt 注册):
# cmake -DVDE_TOOL=<tool> -DVDE_SOURCE_DIR=<src> -DVDE_BINARY_DIR=<build> \
# -DVDE_GENERATOR=<gen> -P index_revocation_smoke.cmake
if(NOT DEFINED VDE_TOOL OR NOT EXISTS "${VDE_TOOL}")
message(FATAL_ERROR "index_revocation_smoke: VDE_TOOL not set or missing: ${VDE_TOOL}")
endif()
if(NOT DEFINED VDE_SOURCE_DIR OR NOT EXISTS "${VDE_SOURCE_DIR}/plugins/templates")
message(FATAL_ERROR "index_revocation_smoke: VDE_SOURCE_DIR invalid: ${VDE_SOURCE_DIR}")
endif()
if(NOT DEFINED VDE_BINARY_DIR OR "${VDE_BINARY_DIR}" STREQUAL "")
message(FATAL_ERROR "index_revocation_smoke: VDE_BINARY_DIR not set")
endif()
set(_generator "${VDE_GENERATOR}")
if(_generator STREQUAL "")
set(_generator "Ninja")
endif()
set(_root "${VDE_BINARY_DIR}/index_revocation_smoke")
file(REMOVE_RECURSE "${_root}")
file(MAKE_DIRECTORY "${_root}")
function(_run_checked)
execute_process(COMMAND ${ARGN} RESULT_VARIABLE _rc OUTPUT_VARIABLE _out ERROR_VARIABLE _err)
if(NOT _rc EQUAL 0)
message(FATAL_ERROR "command failed (${_rc}): ${ARGN}\nstdout:\n${_out}\nstderr:\n${_err}")
endif()
endfunction()
# 期望失败;needle 非空时要求 stdout+stderr 包含该诊断(如 revoked / parse)。
function(_run_expect_fail needle)
execute_process(COMMAND ${ARGN} RESULT_VARIABLE _rc OUTPUT_VARIABLE _out ERROR_VARIABLE _err)
if(_rc EQUAL 0)
message(FATAL_ERROR "command unexpectedly succeeded: ${ARGN}\nstdout:\n${_out}")
endif()
if(NOT needle STREQUAL "")
string(FIND "${_out}${_err}" "${needle}" _pos)
if(_pos EQUAL -1)
message(FATAL_ERROR
"missing diagnostic \"${needle}\" for: ${ARGN}\nstdout:\n${_out}\nstderr:\n${_err}")
endif()
endif()
endfunction()
# 1) 生成一个可构建插件包(复用 format 模板),并用 A 密钥签名索引。
file(MAKE_DIRECTORY "${_root}/repo/com.acme.revoke")
_run_checked("${VDE_TOOL}" scaffold format "com.acme.revoke" --out "${_root}/pkg-src"
--templates "${VDE_SOURCE_DIR}/plugins/templates")
_run_checked("${CMAKE_COMMAND}" -S "${_root}/pkg-src" -B "${_root}/pkg-build"
-G "${_generator}" -DCMAKE_BUILD_TYPE=Release "-DVDE_SDK_DIR=${VDE_SOURCE_DIR}")
_run_checked("${CMAKE_COMMAND}" --build "${_root}/pkg-build" --config Release)
file(COPY "${_root}/pkg-build/plugin/" DESTINATION "${_root}/repo/com.acme.revoke")
_run_checked("${VDE_TOOL}" --gen-keypair --out-dir "${_root}/keysA")
_run_checked("${VDE_TOOL}" --gen-keypair --out-dir "${_root}/keysB")
_run_checked("${VDE_TOOL}" --build-index "${_root}/repo" -o "${_root}/index.json"
--sign "${_root}/keysA/plugin_signing.key" --key-id "revoke-key-A"
--publisher "Revocation Test")
file(WRITE "${_root}/revokedA.txt" "revoke-key-A\n")
file(WRITE "${_root}/revokedB.txt" "revoke-key-B\n")
file(WRITE "${_root}/revokedA.json" "{\"revoked_key_ids\": [\"revoke-key-A\"]}\n")
file(WRITE "${_root}/revoked_bad.json" "{not-json\n")
# 2) verify-index + 吊销(行/JSON 拒绝,不同 key 放行,格式错误明确诊断)。
_run_expect_fail("revoked" "${VDE_TOOL}" --verify-index "${_root}/index.json"
--pubkey "${_root}/keysA/plugin_signing.pub" --revoked-keys "${_root}/revokedA.txt")
_run_checked("${VDE_TOOL}" --verify-index "${_root}/index.json"
--pubkey "${_root}/keysA/plugin_signing.pub" --revoked-keys "${_root}/revokedB.txt")
_run_expect_fail("revoked" "${VDE_TOOL}" --verify-index "${_root}/index.json"
--pubkey "${_root}/keysA/plugin_signing.pub" --revoked-keys "${_root}/revokedA.json")
_run_expect_fail("parse" "${VDE_TOOL}" --verify-index "${_root}/index.json"
--pubkey "${_root}/keysA/plugin_signing.pub" --revoked-keys "${_root}/revoked_bad.json")
# 3) install/upgrade 同样强制吊销(不同 key 正常安装)。
_run_expect_fail("revoked" "${VDE_TOOL}" --install "${_root}/index.json"
--dest "${_root}/destA" --pubkey "${_root}/keysA/plugin_signing.pub"
--revoked-keys "${_root}/revokedA.txt")
_run_checked("${VDE_TOOL}" --install "${_root}/index.json" --dest "${_root}/destB"
--pubkey "${_root}/keysA/plugin_signing.pub" --revoked-keys "${_root}/revokedB.txt")
_run_expect_fail("revoked" "${VDE_TOOL}" --upgrade "${_root}/index.json"
--id "com.acme.revoke" --dest "${_root}/destB" --pubkey "${_root}/keysA/plugin_signing.pub"
--revoked-keys "${_root}/revokedA.txt")
message(STATUS "index_revocation_smoke: PASS (verify/install/upgrade revoked rejection + different-key allow + bad format)")