sigstore/sigstore-conformance
GitHub: sigstore/sigstore-conformance
Sigstore 客户端一致性测试框架,用于验证各类 Sigstore 客户端实现是否严格遵循官方架构规范。
Stars: 13 | Forks: 18
# sigrule-conformance
[](https://github.com/sigstore/sigstore-conformance/actions/workflows/ci.yml)
[](https://github.com/sigstore/sigstore-conformance/actions/workflows/conformance.yml)
`sigstore-conformance` 是一个用于 Sigstore 客户端的一致性测试套件。
已知客户端的测试结果每日发布在
[Sigstore Client Conformance Report](https://sigstore.github.io/sigstore-conformance)。
本套件提供客户端整体行为的高层级视图,旨在回答如下问题:
- 在签名工作流中,如果给定的签名证书不是由 Fulcio root CA 签发的,客户端是否会失败?
- 在验证工作流中,如果给定来自 Rekor 的无效包含证明,客户端是否会失败?
- 在签名工作流中,如果给定作为 Fulcio 响应一部分的无效签名证书时间戳,客户端是否会失败?
- 等等
官方 Sigstore 客户端正作为 [Sigstore Architecture Documentation](https://github.com/sigstore/architecture-docs) 的一部分制定中。
一旦完成,`sigstore-conformance` 旨在测试客户端对规范的遵守情况。
本套件的一些通用测试原则如下:
- *测试应侧重于“工作流”。* 本测试套件不是为了对客户端 CLI 的每一个可能输入进行模糊测试或实现代码覆盖率。
- *测试应端到端地运行整个客户端,而不是孤立地测试单个子系统。* 测试应包括与 Sigstore 基础设施(如 Rekor、Fulcio 等)的所有网络交互。这些测试应在 Sigstore staging 和 production 基础设施以及定制构建的模拟服务上运行,以测试非典型场景。
- *大多数验证测试可以在不编写新代码的情况下进行参数化。* 参见
[test/assets/bundle-verify/README](test/assets/bundle-verify/README.md)
## 用法
1. 在你的项目中包含一个实现了被测客户端 [CLI 协议](docs/cli_protocol.md) 的可执行文件。
2. 在你的测试工作流中使用 `sigstore/sigstore-conformance` action:
jobs:
conformance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# 在此插入你的客户端安装步骤
# 针对 production Sigstore 环境运行测试
- uses: sigstore/sigstore-conformance@v0.0.25
with:
entrypoint: my-conformance-client
# 针对 staging Sigstore 环境运行测试
- uses: sigstore/sigstore-conformance@v0.0.25
with:
entrypoint: my-conformance-client
environment: staging
完整示例请参见 [自测工作流](https://github.com/sigstore/sigstore-python/blob/main/.github/workflows/conformance.yml)。
### `sigstore/sigstore-conformance` action 输入
重要的 action 输入包括
* `entrypoint`:必需字符串。一个实现了被测客户端 [CLI 协议](docs/cli_protocol.md) 的命令
* `environment`:'production'(默认)或 'staging'。选择要运行的 Sigstore 环境
* `xfail`:可选字符串。以空格分隔的预期失败的测试名称。可以使用 Shell 风格的通配符(例如 `test_verify*intoto*`)。注意某些测试名称中使用的“[”是一个通配符字符,可以用例如“[[]”来匹配。
完整输入列表请参见 [action.yml](action.yml)。
### 为可选测试配置 `xfail`
[[示例]](https://github.com/sigstore/sigstore-conformance/blob/eae6eb1f59e25c6d3d602c5dad3dc55767c2f1cb/.github/workflows/conformance.yml#L44)
根据客户端的可选功能支持,可以将以下测试模式添加到 `xfail` 配置中
- `test_verify*intoto*`:较旧的、已弃用的 intoto 类型,对于新客户端可以忽略。
- `test_verify*managed-key-happy-path]`,`test_verify*managed-key-and-trusted-root]`:要求客户端支持托管密钥的测试
## 开发
在本地运行一致性套件最简单的方法是使用提供的虚拟环境:
```
$ make dev
$ source env/bin/activate
(env) $
```
测试套件可以通过以下方式配置
* `--entrypoint=$SIGSTORE_CLIENT`,其中 SIGSTORE_CLIENT 是实现 [CLI 规范](https://github.com/sigstore/sigstore-conformance/blob/main/docs/cli_protocol.md) 的脚本路径
* 可选 `--staging`:指示测试套件针对 Sigstore staging 基础设施运行
* 可选 `--skip-signing`:仅运行验证测试
* 环境变量 `GHA_SIGSTORE_CONFORMANCE_XFAIL` 可用于设置预期失败
```
(env) $ # run all tests
(env) $ pytest -v --entrypoint=$SIGSTORE_CLIENT
(env) $ # run verification tests only
(env) $ pytest -v --entrypoint=$SIGSTORE_CLIENT --skip-signing
```
以下示例使用包含的自测客户端脚本运行测试套件:
```
(env) $ # run all tests
(env) $ GHA_SIGSTORE_CONFORMANCE_XFAIL="test_verify*-intoto-with-custom-trust-root] test_verify*managed-key-happy-path] test_verify*managed-key-and-trusted-root]" \
pytest -v --entrypoint=selftest-client
...
(env) $ # run single test
(env) $ pytest -v --entrypoint=selftest-client -k test_verify[DIGEST-happy-path]
...
```
## 许可
`sigstore-conformance` 根据 Apache 2.0 许可证授权。
## 行为准则
与本项目交互的每个人都应遵守 [sigstore 行为准则](https://github.com/sigstore/.github/blob/main/CODE_OF_CONDUCT.md)
## 安全
如果您发现任何安全问题,请参阅 sigstore 的 [安全流程](https://github.com/sigstore/.github/blob/main/SECURITY.md)。
标签:CA验证, Fulcio, Golang, Mock服务, Rekor, Sigstore, 一致性测试, 代码签名, 安全工作流, 安全编程, 安全规则引擎, 客户端测试, 数字签名验证, 架构文档, 测试套件, 端到端测试, 符合性测试, 证书验证, 软件供应链安全, 远程方法调用, 逆向工具