implementing-code-signing-for-artifacts
本技能涵盖为构建产物实施代码签名,以确保软件供应链中的完整性和真实性。 内容包括使用 GPG、Sigstore 和平台专用签名工具对二进制文件、软件包和容器进行签名, 建立信任链,以及在部署管道中验证签名。
Best use case
implementing-code-signing-for-artifacts is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
本技能涵盖为构建产物实施代码签名,以确保软件供应链中的完整性和真实性。 内容包括使用 GPG、Sigstore 和平台专用签名工具对二进制文件、软件包和容器进行签名, 建立信任链,以及在部署管道中验证签名。
Teams using implementing-code-signing-for-artifacts should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/implementing-code-signing-for-artifacts/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How implementing-code-signing-for-artifacts Compares
| Feature / Agent | implementing-code-signing-for-artifacts | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
本技能涵盖为构建产物实施代码签名,以确保软件供应链中的完整性和真实性。 内容包括使用 GPG、Sigstore 和平台专用签名工具对二进制文件、软件包和容器进行签名, 建立信任链,以及在部署管道中验证签名。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 为构建产物实施代码签名
## 使用场景
- 建立产物完整性验证以防止供应链篡改时
- 合规要求需要密码学证明构建产物真实且未被修改时
- 向需要验证发布者身份的客户分发软件时
- 实施零信任部署管道以拒绝未签名产物时
- 满足 SLSA Level 2+ 的来源和完整性要求时
**不适用于**加密产物(签名提供完整性,而非保密性)、专门用于容器镜像签名(使用 cosign)或源代码身份验证(使用提交签名)。
## 前置条件
- 用于传统签名的 GPG 密钥对,或用于无密钥签名的 Sigstore 账号
- 来自证书颁发机构的代码签名证书(用于公开发布)
- 能够访问签名密钥或身份提供者的 CI/CD 管道
- 部署管道中的验证基础设施
## 操作流程
### 步骤 1:生成和管理签名密钥
```bash
# 生成用于产物签名的 GPG 密钥
gpg --full-generate-key --batch <<EOF
Key-Type: eddsa
Key-Curve: ed25519
Subkey-Type: eddsa
Subkey-Curve: ed25519
Name-Real: CI Build System
Name-Email: ci-signing@company.com
Expire-Date: 1y
%no-protection
EOF
# 导出公钥用于分发
gpg --armor --export ci-signing@company.com > signing-key.pub
# 导出私钥用于 CI/CD(存储在密钥管理器中)
gpg --armor --export-secret-keys ci-signing@company.com > signing-key.priv
```
### 步骤 2:在 CI/CD 中签名构建产物
```yaml
# .github/workflows/build-sign.yml
name: Build and Sign
on:
push:
tags: ['v*']
jobs:
build-sign:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # 用于 Sigstore 无密钥签名
steps:
- uses: actions/checkout@v4
- name: Build artifacts
run: |
make build
sha256sum dist/* > dist/checksums.sha256
- name: Import GPG Key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
gpg --list-secret-keys
- name: Sign artifacts
run: |
for file in dist/*; do
gpg --detach-sign --armor --local-user ci-signing@company.com "$file"
done
- name: Install cosign for keyless signing
uses: sigstore/cosign-installer@v3
- name: Keyless sign with Sigstore
run: |
for file in dist/*.tar.gz; do
cosign sign-blob "$file" \
--output-signature "${file}.sig" \
--output-certificate "${file}.cert" \
--yes
done
- name: Create Release with signed artifacts
uses: softprops/action-gh-release@v2
with:
files: |
dist/*
dist/*.asc
dist/*.sig
dist/*.cert
```
### 步骤 3:在部署管道中验证签名
```bash
# 验证 GPG 签名
gpg --import signing-key.pub
gpg --verify artifact.tar.gz.asc artifact.tar.gz
# 验证 Sigstore 无密钥签名
cosign verify-blob artifact.tar.gz \
--signature artifact.tar.gz.sig \
--certificate artifact.tar.gz.cert \
--certificate-identity ci-signing@company.com \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
# 验证校验和
sha256sum --check checksums.sha256
```
### 步骤 4:使用来源信息签名 npm 包
```json
{
"scripts": {
"prepublishOnly": "npm run build && npm run test"
},
"publishConfig": {
"provenance": true
}
}
```
```bash
# 发布带来源证明的 npm 包
npm publish --provenance
```
## 关键概念
| 术语 | 定义 |
|------|------|
| 代码签名 | 对软件产物进行签名的密码学过程,用于验证发布者身份和产物完整性 |
| 分离签名 | 签名存储在与产物分离的文件中,允许独立分发 |
| 无密钥签名 | Sigstore 的方法,使用与 OIDC 身份绑定的短期证书,而非长期密钥 |
| 来源 | 描述产物构建方式、地点和构建者的元数据 |
| 透明日志 | 记录所有签名事件以供公开审计的仅追加日志(Rekor) |
| 信任链 | 从根 CA 到签名证书的层级链,建立对签名者身份的信任 |
| SLSA | 软件产物供应链级别 — 定义供应链安全级别的框架 |
## 工具与系统
- **GPG/PGP**:传统的非对称加密工具,用于签名和验证产物
- **Sigstore (cosign)**:使用 OIDC 身份和透明日志的现代无密钥签名基础设施
- **Rekor**:Sigstore 的透明日志,不可变地记录所有签名事件
- **Fulcio**:Sigstore 的证书颁发机构,颁发与 OIDC 身份绑定的短期证书
- **notation**:Microsoft 用于 OCI 镜像仓库的产物签名工具(Project Notary v2)
## 常见场景
### 场景:建立已签名的发布管道
**背景**:一个开源项目需要对发布产物进行签名,以便用户可以验证真实性并检测篡改。
**方法**:
1. 在 GitHub Actions 中使用 Sigstore 无密钥签名(无需密钥管理开销)
2. 使用 OIDC 身份通过 `cosign sign-blob` 签名所有发布二进制文件
3. 生成并签名校验和文件用于批量验证
4. 将签名、证书和校验和与发布产物一起上传
5. 在项目 README 中记录验证说明
6. 在 Homebrew formula 或 apt 仓库中添加验证步骤
**注意事项**:GPG 密钥泄露需要撤销并重新签名所有产物。Sigstore 无密钥签名通过使用短期密钥避免了这一问题。CI/CD 密钥中的长期签名密钥如果 CI 系统被入侵,将带来供应链风险。
## 输出格式
```
产物签名报告
========================
管道:Build and Sign v2.3.0
日期:2026-02-23
签名方法:Sigstore 无密钥 + GPG
已签名产物:
app-v2.3.0-linux-amd64.tar.gz
GPG: 通过(ci-signing@company.com,EdDSA/Ed25519)
Sigstore: 通过(Rekor 条目:24658135,Fulcio 证书已颁发)
SHA256: a1b2c3d4...
app-v2.3.0-darwin-arm64.tar.gz
GPG: 通过
Sigstore: 通过(Rekor 条目:24658136)
SHA256: e5f6g7h8...
checksums.sha256
GPG: 通过(分离签名)
透明日志:
已记录条目:3
日志索引范围:24658135-24658137
验证:https://search.sigstore.dev
```Related Skills
investigating-ransomware-attack-artifacts
识别、收集和分析勒索软件攻击制品,以确定变种、初始访问向量、加密范围和恢复选项。
implementing-zero-trust-with-hashicorp-boundary
使用 HashiCorp Boundary 实现具备动态凭据代理、会话录制和 Vault 集成的身份感知零信任基础设施访问管理。
implementing-zero-trust-with-beyondcorp
使用身份感知代理(IAP,Identity-Aware Proxy)、上下文感知访问策略、设备信任验证和 Access Context Manager,部署 Google BeyondCorp Enterprise 零信任访问控制,对 GCP 资源和内部应用强制执行基于身份和安全态势的访问。
implementing-zero-trust-network-access
通过配置身份感知代理、微分段、基于条件访问策略的持续验证,以及在 AWS、Azure 和 GCP 环境中以 BeyondCorp 风格的架构替代传统 VPN 访问,在云环境中实施零信任网络访问(ZTNA)。
implementing-zero-trust-network-access-with-zscaler
使用 Zscaler 实施零信任网络访问(Zero Trust Network Access,ZTNA),通过 Zscaler Private Access(ZPA)配置应用分段、访问策略和连接器,替代传统 VPN 架构
implementing-zero-trust-in-cloud
本技能指导组织按照 NIST SP 800-207 和 Google BeyondCorp 原则在云环境中实施零信任(Zero Trust)架构,涵盖以身份为中心的访问控制、微分段(Micro-Segmentation)、持续验证、设备信任评估,以及部署身份感知代理(Identity-Aware Proxy)以消除 AWS、Azure 和 GCP 环境中的隐式网络信任。
implementing-zero-trust-for-saas-applications
使用 CASB、SSPM、条件访问策略、OAuth 应用治理和会话控制,为 SaaS 应用实施零信任访问控制, 对云托管服务强制执行身份验证、设备合规性检查和数据保护。
implementing-zero-trust-dns-with-nextdns
将 NextDNS 实施为零信任 DNS 过滤层,提供加密解析、威胁情报阻断、隐私保护,以及跨所有端点的组织策略执行。
implementing-zero-standing-privilege-with-cyberark
部署 CyberArk Secure Cloud Access,通过基于时间、权限和审批控制的即时访问,在混合云和多云环境中消除常设权限。
implementing-zero-knowledge-proof-for-authentication
零知识证明(ZKP)允许证明者在不泄露秘密本身的情况下证明对某个秘密(如密码或私钥)的了解。本技能实现 Schnorr 身份识别协议和使用离散对数问题的简化 ZKPP,使服务器永远不需要获取用户密码即可完成认证。
implementing-web-application-logging-with-modsecurity
配置带有 OWASP 核心规则集(CRS)的 ModSecurity WAF,实现 Web 应用程序日志记录, 调整规则以减少误报,分析审计日志进行攻击检测,并为应用程序特定威胁实现自定义 SecRules。 分析师配置 SecRuleEngine、SecAuditEngine 和 CRS 偏执级别,以在安全覆盖范围和运营稳定性之间取得平衡。 适用于涉及 WAF 配置、ModSecurity 规则调整、Web 应用审计日志或 CRS 部署的场景。
implementing-vulnerability-sla-breach-alerting
为漏洞修复 SLA 违规构建自动化告警,包含基于严重程度的时间线、升级工作流和合规性报告仪表板。