hancoinkr/workers-release-proof

GitHub: hancoinkr/workers-release-proof

为 Cloudflare Workers 提供故障关闭、内容寻址的发布凭证,确保审查的代码、构建产物与实际部署版本完全一致。

Stars: 0 | Forks: 0

# Workers Release 证明 [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/hancoinkr/workers-release-proof/actions/workflows/ci.yml) [![Production reference](https://static.pigsec.cn/wp-content/uploads/repos/cas/0e/0e9baabc2eb2dfea3730240245035e905db6a588e0754ba579010ba981297be2.svg)](https://github.com/hancoinkr/workers-release-proof/actions/workflows/production-reference.yml) [![Release](https://img.shields.io/github/v/release/hancoinkr/workers-release-proof)](https://github.com/hancoinkr/workers-release-proof/releases) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE) [![Node.js 22+](https://img.shields.io/badge/Node.js-22%2B-339933.svg)](https://nodejs.org/) 为 Cloudflare Workers 提供故障关闭(fail-closed)、内容寻址的发布凭证。 Workers Release Proof 证明你审查的 commit、你构建的 artifact、你预期的 D1 migrations 以及你观察到的发布状态是同一个发布版本。它仅存储哈希值和公开结构,绝不存储凭证值。 ## 为什么需要 常规的 CI 可以表明构建成功了。但这并不一定能证明: - 工作树是干净的; - 部署的 artifact 来源于已审查的 commit; - migration 集合未被更改; - Worker 绑定与已审查的配置相匹配; - 实时的健康检查 endpoint 报告了相同的 commit 和 artifact; - 回滚元数据指向的是一个实际被观察到的先前发布版本。 Workers Release Proof 将这些事实绑定到一个确定性的 JSON 文档中。任何缺失或不匹配的事实都会导致门禁失败。 ## 功能 - 用于构建 artifact 的确定性 SHA-256 树摘要; - Git commit 和干净工作树绑定; - D1 migration 名称、大小和 SHA-256 清单; - 净化后的 Wrangler 绑定清单,仅保留变量名而不包含值; - 使用发布占位符的可配置实时健康状态断言; - 回滚元数据验证; - 跟踪文件的 secret 扫描,仅报告位置而不打印具体值; - 独立的 CLI 和复合 GitHub Action; - 零运行时依赖,支持 Node.js 22+。 ## 快速开始 ``` npm install --save-dev github:hancoinkr/workers-release-proof#v0.1.3 cp node_modules/workers-release-proof/release-proof.config.example.json \ release-proof.config.json npx workers-release-proof scan npx workers-release-proof inspect npx workers-release-proof verify ``` 默认的凭证文件是 `.release-proof/evidence.json`。 该包目前通过固定的 GitHub releases 分发,而不是 npm 注册表。发布压缩包会获得公开的 GitHub artifact 证明。 ## 配置 ``` { "schemaVersion": 1, "artifactDirectories": ["dist", ".wrangler/dry-run"], "migrationDirectories": ["migrations"], "wranglerConfig": "wrangler.jsonc", "wranglerEnvironment": "production", "maxEvidenceAgeMinutes": 60, "requireCleanWorktree": true, "healthChecks": [ { "id": "worker-health", "url": "https://example.com/api/health", "expectedStatus": 200, "assertions": [ { "path": "status", "equals": "ok" }, { "path": "release.commitSha", "equals": "$commitSha" }, { "path": "release.artifactSha256", "equals": "$artifactSha256" } ] } ], "secretScan": { "exclude": ["test/fixtures/"] } } ``` `$commitSha` 和 `$artifactSha256` 根据候选发布版本进行解析。健康检查响应会被计算哈希值;响应正文不会被写入凭证文件。 使用 Wrangler `--env` 进行部署时,请设置 `wranglerEnvironment`;绑定将从该命名环境中解析,且原始资源标识符将保持私密。 ## 命令 ``` workers-release-proof scan workers-release-proof inspect workers-release-proof verify workers-release-proof help ``` 常用 flag: ``` --root Repository root --config Configuration path --evidence Evidence path --json Machine-readable output ``` ## GitHub Action ``` - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: hancoinkr/workers-release-proof@v0.1.3 with: config: release-proof.config.json ``` 该 Action 会扫描跟踪的文件,从检出的 commit 创建凭证,并立即对其进行验证。 ## 生产环境参考 首个由维护者运营的生产环境应用验证了一个包含 245 个文件的 Worker artifact 集合、27 个 D1 migration、净化后的 Wrangler 结构,以及 [BitcoinKevin](https://bitcoinkevin.com/) 的公开健康检查 endpoint。公开的脱敏凭证和计划的实时验证记录在 [docs/production-reference.md](docs/production-reference.md) 中。 这是第一方的生产环境使用,并非独立的第三方采用。在其他维护者发布可复现的集成之前,将始终保持这一区别的明确性。 ## 安全特性 - 在生成凭证时绝不会读取环境变量的值。 - Wrangler 的 `vars` 仅按键名记录。 - D1、R2、KV、service、queue 和 analytics 绑定仅按绑定名称和类型记录。 - URL 在存储前会去除凭证信息。 - 发现的 secret 仅包含规则、文件和行号。 - 脏工作树、更改的 artifact、更改的 migration、过期的凭证、缺失的健康断言或回滚不匹配都会导致故障关闭。 在生产发布工作流中使用此工具之前,请阅读 [docs/security-model.md](docs/security-model.md)。 ## 项目起源 该设计源自一个生产环境的 Cloudflare Workers 发布 pipeline,该 pipeline 绑定了源代码 commit、构建 artifact、D1 migration、实时健康状态和回滚凭证。本仓库特意排除了特定于产品的名称、ID、商业变现、支付、用户和运营逻辑。 ## 许可证 Apache-2.0
标签:MITM代理, 程序员工具, 自定义脚本, 高对比度