软件供应链安全

SLSA 框架等级

等级要求防护
SLSA 1构建过程脚本化/自动化;生成来源信息意外错误
SLSA 2版本控制构建、托管构建服务、签名来源基本篡改
SLSA 3强化构建平台、可审计构建流程内部威胁
SLSA 4双人审查、隔离构建、可复现构建复杂攻击

依赖审计命令

# npm npm audit npm audit fix npm audit --audit-level=high # Python pip-audit safety check -r requirements.txt # Go govulncheck ./... # GitHub Dependabot (.github/dependabot.yml) version: 2 updates: - package-ecosystem: "npm" directory: "/" schedule: interval: "weekly" open-pull-requests-limit: 10

SBOM 生成

# CycloneDX 格式(推荐) # npm cyclonedx-npm --output-format json --output-file sbom.json # Python cyclonedx-bom -r -o sbom.xml # Go cyclonedx-gomod app -output bom.json # Syft(多语言) syft packages dir:. -o cyclonedx-json=sbom.json

供应链安全清单

  • 固定依赖版本(锁定文件)——生产环境不使用范围版本
  • 验证下载包的校验和/哈希
  • 使用私有包仓库缓存和审核包
  • 用 Sigstore/Cosign 签名所有构建产物
  • 在 CI 流水线中实施 SCA(软件成分分析)
  • 所有发布版本生成 SBOM
  • 添加新依赖前先审查(评估维护情况、流行度、许可证)
  • 监控已使用包的新 CVE(Dependabot、Snyk)
  • 使用隔离构建(构建期间无网络访问)
  • 保护 CI/CD 管道凭据和密钥