aflock-ai/rookery
GitHub: aflock-ai/rookery
Rookery 是一个模块化的 Go 供应链证明工具包,用于在软件开发生命周期各环节生成、签名并验证 SLSA/in-toto 证明证据。
Stars: 8 | Forks: 1
# Rookery
**面向 Go 的模块化供应链证明工具包。** 在 SDLC 的每一个环节(本地开发、CI、发布、部署)构建 SLSA / in-toto 证据,并通过策略进行验证。
Rookery 是 **[`cilock`](cilock/)**(兼容 witness 的证明 CLI)、**[`attestation`](attestation/)** 库、50+ 个证明器插件(参见 [`docs/attestor-catalog.md`](docs/attestor-catalog.md))、可插拔的签名器集合(file、Fulcio、KMS、Vault、Vault-Transit、SPIFFE)以及 **[`builder`](builder/)** 的上游项目,该 builder 可生成仅包含所需插件的自定义二进制文件。

*一段真实且无脚本的 Claude Code 会话:`cilock` 在 eBPF 内核侧追踪下封装了 Trivy 扫描,并将结果作为 in-toto 证明进行签名——绝无造假。*
## 您实际获得的功能
| 您想要… | 使用 |
|---|---|
| 封装构建步骤并生成已签名的证据 | `cilock run` |
| 在不封装命令的情况下记录证明 | `cilock attest` |
| 根据策略验证证明链 | `cilock verify` |
| 将证据打包为可移植的 bundle | `cilock bundle` |
| 检查每个文件的包含证明(内联在 v0.3 产品证明中) | 携带证明的内联叶子节点执行 `cilock verify` |
| 管理和验证 Witness 策略 | `cilock policy` |
| 将证明嵌入到您自己的 Go 程序中 | [`attestation`](attestation/) 库 |
| 发布仅包含所需证明器的更精简 CLI | [`builder`](builder/) |
| 无缝接入 GitHub Actions 工作流 | [`aflock-ai/cilock-action`](https://github.com/aflock-ai/cilock-action) |
运行 `cilock --help` 获取完整的命令列表(`attest`、`bundle`、`policy`、`plan`、`tools`、`sign`、`login`、`whoami` 等)。
## 快速开始
```
# 安装 cilock (兼容 witness 的 CLI,包含所有 plugins)
go install github.com/aflock-ai/rookery/cilock/cmd/cilock@latest
# 封装一个构建步骤 — 生成一个 in-toto/DSSE attestation
# (product 和 material 总是会被记录;传入 --platform-url "" 以进行完全离线签名)
cilock run \
--step build \
--attestations command-run,environment,git \
--signer-file-key-path cosign.key \
--outfile build.attestation.json \
--platform-url "" \
-- go build ./...
# 列出编译进此二进制文件的每个 attestor
cilock attestors list
```
有关配置签名后端和托管平台的信息,请参见 [`docs/configuration.md`](docs/configuration.md)
和 [`docs/signers.md`](docs/signers.md);有关标准的证明器名称和 predicate 类型,请参见
[证明器目录](docs/attestor-catalog.md)。`cilock run --help` 和 `cilock verify --help` 记录了
完整的签名、追踪和 Archivista 参数标志。
## 目录结构
```
rookery/
├── attestation/ # Core library: AttestationContext, Attestor interface, DSSE envelope
├── cilock/ # Batteries-included CLI (witness-compatible)
├── plugins/
│ ├── attestors/ # 50+ attestors, each its own Go module
│ └── signers/ # file, fulcio, kms (aws|azure|gcp), spiffe, vault, vault-transit, debug-signer
├── presets/ # Curated plugin sets (minimal, cicd, all) — blank-import these
├── builder/ # Generate custom cilock binaries with a chosen plugin set
├── compat/ # Import shims for the legacy witness.dev module paths
└── docs/
└── attestor-catalog.md # Canonical attestor names + predicate types
```
**模块路径约定:** `github.com/aflock-ai/rookery/...`
**每个插件都有独立的 `go.mod`**,因此您可以仅依赖例如 `plugins/attestors/git`,而无需引入整个依赖树。
## 三种使用方式
### 1. 使用预构建的 `cilock` CLI
默认的二进制文件包含了所有的证明器和一套合理的签名器集合。最适合入门、CI 和内部测试使用。
### 2. 使用 `builder` 构建自定义 CLI
仅选择您要发布的插件——二进制文件更小,传递依赖树也更小。
```
cd builder
go run ./cmd/builder/ --preset minimal --local --output /tmp/cilock-min
/tmp/cilock-min attestors list
```
预设:`minimal`(commandrun + environment + git + material + product,以及 file 签名器),
`cicd`(minimal + github、gitlab、slsa),`all`(所有证明器 + 所有签名器)。运行
`go run ./cmd/builder/ --help` 查看 manifest 格式以及 `--with`、`--fips` 和 `--manifest` 参数标志。
### 3. 嵌入库
高级入口是 `workflow.RunWithExports`,它会构建证明上下文,运行
证明器,并将集合签名后封装进 DSSE envelope 中。空导入(Blank-import)您需要注册的证明器和签名器插件,然后通过 `RunWithSigners` 传入 `cryptoutil.Signer`:
```
import (
"github.com/aflock-ai/rookery/attestation"
"github.com/aflock-ai/rookery/attestation/workflow"
_ "github.com/aflock-ai/rookery/plugins/attestors/git" // register the git attestor
_ "github.com/aflock-ai/rookery/plugins/signers/file" // register the file signer
)
results, err := workflow.RunWithExports("build",
workflow.RunWithAttestors([]attestation.Attestor{ /* attestors */ }),
workflow.RunWithAttestationOpts(attestation.WithWorkingDir("./")),
workflow.RunWithSigners(signer))
// results[0].SignedEnvelope is the signed dsse.Envelope
```
请参见 [`cilock/cli/run.go`](cilock/cli/run.go) 和 [`attestation/workflow`](attestation/workflow/)
包以了解完整的连接细节(签名器提供者解析、时间戳服务、Archivista 导出)。
## Witness / aflock 兼容性
Rookery 是 **[in-toto/witness](https://github.com/in-toto/witness)** 的树内延续版本,包含针对破坏性 Bug 的修复(参见 [`witnessfixes.md`](witnessfixes.md))以及新的 aflock predicate 命名空间(`https://aflock.ai/attestations/...`)。遗留的 `witness.dev` predicate 类型依然会在启动时通过注册的别名进行调用,因此由 `witness` 生成的链可以在 `cilock` 下验证,反之亦然。
默认的 `cilock` 二进制文件保留了两者注册信息,因此可以在混合环境中工作。如果您通过 `builder` 构建自定义二进制文件,别名仍会被注册。
## 插件目录
[`docs/attestor-catalog.md`](docs/attestor-catalog.md) 列出了所有已注册的证明器——第 1 列中的**标准名称**就是您传递给 `--attestations`(或 `cilock-action` 的 `attestations:` 输入项)的内容。它并不总是与目录名称相同(`commandrun` 注册为 `command-run`,`aws-iid` 注册为 `aws` 等)。不匹配会快速失败并提示 `attestor not found`。
在添加或重命名证明器后重新生成:
```
make docs # runs scripts/gen-attestor-catalog.sh
```
## 开发
```
git clone https://github.com/aflock-ai/rookery.git
cd rookery
make build # build every module via go.work
make test # run all tests
make lint # golangci-lint across the workspace
make verify-isolated # confirm each module builds without go.work
make help # list all targets
```
该仓库使用 **`go.work`** 进行本地开发。CI 也会在隔离环境下运行各个模块(`GOWORK=off`),以捕获意外的跨模块耦合。
Go 版本固定在 **`.go-version`** 中;每个 `go.mod` 都必须与之匹配。CI 会对此进行强制检查。
有关签名提交设置、conventional-commit 格式以及“添加新插件”的检查清单,请参见 [`CONTRIBUTING.md`](CONTRIBUTING.md)。
## 版本控制
带路径前缀的标签(标准 Go 多模块约定):
```
attestation/v0.1.0
plugins/attestors/git/v0.1.0
plugins/signers/file/v0.1.0
cilock/v0.1.0
```
## 许可证与来源
Apache 2.0。请参见 [`LICENSE`](LICENSE) 和 [`NOTICE.md`](NOTICE.md)。
从上游项目中内联的任何内容都在 `.provenance/*.json` 中进行了跟踪——每个条目都固定了上游提交、许可证 SPDX,以及针对上游和本地副本的 SHA256。CI 会在每次 PR 时通过 [`scripts/check-provenance.sh`](scripts/check-provenance.sh) 重新验证。
## 相关项目
- **[`aflock-ai/cilock-action`](https://github.com/aflock-ai/cilock-action)** — GitHub Action 封装
- **[`aflock-ai/supply-chain-attacks`](https://github.com/aflock-ai/supply-chain-attacks)** — 真实攻击目录 + cilock 检测
- **[`testifysec/judge`](https://github.com/testifysec/judge)** — 证明收集与验证平台
- **[`in-toto/witness`](https://github.com/in-toto/witness)** — 上游渊源
标签:DevSecOps, Docker镜像, EVTX分析, Go, RDFlib, Ruby工具, SLSA, 上游代理, 代码签名, 日志审计, 跌倒检测, 软件物料清单