ej-east/redoubt

GitHub: ej-east/redoubt

「红堡」是一个提供安全加固容器镜像和自动化CI工作流的开源项目,解决了容器供应链安全中的合规与可追溯性问题。

Stars: 1 | Forks: 0

# 红堡 `redoubt` 是一系列经过加固、可复现的容器镜像和可重用的 CI 工作流集合,用于构建、扫描、签名和认证。`redoubt` 使下游服务能够轻松地在已知的安全基础上发布,无需重复构建供应链环节。 ## 概述 本仓库中的每个镜像都经过相同的流水线: ![流水线示意图](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/2a86b64e77030350.png) 1. **构建** - [Buildx](https://github.com/docker/buildx) 使用一个精简基础镜像(通用镜像使用 [distroless](https://github.com/GoogleContainerTools/distroless),FIPS 镜像使用 UBI Micro)构建多架构镜像 (`linux/amd64`, `linux/arm64`)。 2. **扫描** - [Trivy](https://github.com/aquasecurity/trivy) 执行安全扫描。它会对高危/严重 CVE 进行拦截,并将一份 [SARIF](https://sarifweb.azurewebsites.net/) 报告上传至 GitHub 代码扫描。 3. **签名** - [Cosign](https://github.com/sigstore/cosign) 使用工作流的 OIDC 身份进行无密钥签名。签名记录会被写入 [Rekor](https://docs.sigstore.dev/logging/overview/)。 4. **认证** - [Syft](https://github.com/anchore/syft) 生成一个 SBOM,随后作为 cosign 认证附加到镜像上。 镜像发布至 GHCR,地址为 `ghcr.io/ej-east/`。构建流水线还在 `.github/workflows/build-redoubt-image.yaml` 暴露了一个可重用的工作流,供下游仓库通过 `uses:` 调用。 ## 快速开始 ### 拉取并运行 拉取 `main` 分支镜像: ``` docker run --rm -p 8080:8080 \ -v "$PWD:/var/www:ro" \ ghcr.io/ej-east/static-base:main ``` 固定到一个不可变的摘要: ``` docker pull ghcr.io/ej-east/static-base@sha256: ``` ### 使用基础镜像 使用静态网页服务器基础镜像。它以 nobody(UID 65532)身份运行,并且是无发行版的。 ``` FROM ghcr.io/ej-east/static-base:latest COPY ./site /var/www ``` ### 使用基础 CI 你可以在你的仓库中添加一个薄调用层,命名为:`.github/workflows/build-.yaml` ``` name: build- on: push: branches: [main] paths: - "images//**" - ".github/workflows/build-.yaml" tags: - "/v*" pull_request: paths: - "images//**" - ".github/workflows/build-.yaml" workflow_dispatch: jobs: build: uses: ej-east/redoubt/.github/workflows/build-redoubt-image.yaml@main with: image-name: permissions: contents: read packages: write id-token: write security-events: write ``` 建议固定到提交 SHA 以缓解可能的供应链攻击。 ### 验证签名镜像 你需要安装 [cosign](https://github.com/sigstore/cosign) ``` cosign verify ghcr.io/ej-east/static-base:latest \ --certificate-identity-regexp 'https://github.com/ej-east/redoubt/\.github/workflows/build-redoubt-image\.yaml@.*' \ --certificate-oidc-issuer https://token.actions.githubusercontent.com ``` 验证/下载 SBOM 认证: ``` cosign verify-attestation \ --type spdxjson \ --certificate-identity-regexp 'https://github.com/ej-east/redoubt/\.github/workflows/build-redoubt-image\.yaml@.*' \ --certificate-oidc-issuer https://token.actions.githubusercontent.com \ ghcr.io/ej-east/static-base:latest ``` ## 镜像目录 | 镜像名称 | 描述 | 是否为 FIPS? | | --------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------- | | `ghcr.io/ej-east/static-base` | 用于 SPA 和文档站点的静态网页服务器镜像。 | 否 | | `ghcr.io/ej-east/golang` / `ghcr.io/ej-east/golang-build` | 此容器设计用于在生产环境中构建和运行 Go 语言镜像。 | 是 | ## 设计决策 ### 不同的基础选项 不同的镜像使用不同的基础选项。例如,`static-base` 使用 Google 的 Distroless 解决方案,而 `golang` 镜像集使用 Red Hat 的通用基础镜像(UBI)。UBI Micro 搭载了经 FIPS 140-3 验证的密码学模块,是联邦工作负载的正确选择。 ### 默认多架构 每个镜像都同时为 `amd64` 和 `arm64` 构建。生产环境越来越多地使用 `arm64` 设备。为这些机器生产可用于生产的镜像至关重要。 ### SLSA 等级 镜像当前满足 **SLSA 构建级别 2** 的要求。这通过以下方式实现:Buildx 使用 `provenance: mode=max` 生成 in-toto 溯源证明。生成的认证由 GitHub Actions 的 OIDC 身份签名,并且构建在 GitHub 托管的运行器上运行。此过程满足了 L2 对托管、认证、不可伪造的溯源证明的要求。 **SLSA 构建级别 3** 在路线图上。达到此级别意味着需要采用 [`slsa-framework/slsa-github-generator`](https://github.com/slsa-framework/slsa-github-generator),而不是当前的流程。驱动力在于 L3 是某些工作负载的 FedRAMP 要求。 ### OpenSCAP 生产镜像使用 [OpenSCAP](https://www.open-scap.org/) 和 [ComplianceAsCode](https://github.com/ComplianceAsCode/content)(SSG)内容,对照 [DISA STIG](https://public.cyber.mil/stigs/) 配置文件进行扫描。 ## 许可证 参见 [LICENSE.md](LICENSE.md)。
标签:CI/CD安全, CI/CD管道, CVE, Docker容器, GitHub Actions, GitHub容器注册表, GPT, Llama, OIDC认证, SBOM生成工具Syft, Web截图, 可重现构建, 可重用工作流, 安全扫描, 安全扫描工具Trivy, 安全证明, 容器安全, 容器镜像构建, 攻击面发现, 数字签名, 无键签名, 时序注入, 构建工具Buildx, 漏洞管理, 签名工具Cosign, 自动笔记, 请求拦截, 跌倒检测, 软件物料清单, 镜像加固