securing-container-registry-images
它能做什么
这个工具可以帮你保护电脑程序中使用的软件包(镜像)。它会检查安全漏洞,确认镜像来自可信来源,并阻止使用不安全的镜像。
适用场景
- ✓在设置软件镜像存储位置的安全措施时。
- ✓在创建自动化流程,用于使用前检查和批准镜像时。
- ✓当你希望确保所用镜像没有被恶意人员篡改时。
技能链接
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/securing-container-registry-images/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我怎样才能在使用程序的镜像前,检查它们是否安全?”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会调用其他程序,分析镜像中已知的问题,并确认镜像的真实性。它可以集成到自动化流程中,用来阻止不安全的镜像。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Securing Container Registry Images
When to Use
- When establishing security controls for container image registries (ECR, ACR, GCR, Docker Hub)
- When building CI/CD pipelines that enforce vulnerability scanning before image promotion
- When implementing image signing and verification to prevent supply chain attacks
- When auditing existing registries for vulnerable, unscanned, or unsigned images
- When compliance requires software bill of materials (SBOM) for deployed container images
Do not use for runtime container security (use Falco or Sysdig), for Kubernetes admission control (use OPA Gatekeeper or Kyverno after establishing registry controls), or for host-level vulnerability scanning (use Amazon Inspector or Qualys).
Prerequisites
- Trivy installed (
brew install trivyorapt install trivy) - Grype installed (
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh) - Cosign installed for image signing (
go install github.com/sigstore/cosign/v2/cmd/cosign@latest) - Syft installed for SBOM generation (
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh) - Container registry access (ECR, ACR, GCR, or private registry)
Workflow
Step 1: Scan Images for Vulnerabilities with Trivy
Run comprehensive vulnerability scans against container images before and after pushing to the registry.
# Scan a local image for vulnerabilities
trivy image --severity HIGH,CRITICAL myapp:latest
# Scan a remote registry image
trivy image --severity HIGH,CRITICAL 123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest
# Scan with JSON output for CI/CD processing
trivy image --format json --output trivy-results.json myapp:latest
# Scan for vulnerabilities AND misconfigurations
trivy image --scanners vuln,misconfig,secret myapp:latest
# Scan a specific image with SBOM output
trivy image --format spdx-json --output sbom.json myapp:latest
# Fail CI/CD if critical vulnerabilities found
trivy image --exit-code 1 --severity CRITICAL myapp:latest
Step 2: Scan with Grype for Additional Coverage
Use Grype as a complementary scanner for broader vulnerability database coverage.
# Scan image with Grype
grype myapp:latest
# Scan with severity threshold
grype myapp:latest --fail-on critical
# Output in JSON for processing
grype myapp:latest -o json > grype-results.json
# Scan an SBOM instead of the image directly
syft myapp:latest -o spdx-json > sbom.json
grype sbom:sbom.json
# Scan a directory-based image export
grype dir:/path/to/image-rootfs
Step 3: Generate Software Bill of Materials (SBOM)
Create SBOMs for all images to maintain an inventory of software components and dependencies.
# Generate SBOM with Syft in SPDX format
syft myapp:latest -o spdx-json > sbom-spdx.json
# Generate SBOM in CycloneDX format
syft myapp:latest -o cyclonedx-json > sbom-cyclonedx.json
# Attach SBOM to the image as an OCI artifact
cosign attach sbom --sbom sbom-spdx.json \
123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest
# Verify SBOM contents
syft myapp:latest -o table | head -50
Step 4: Sign Images with Cosign and Sigstore
Implement image signing to ensure image integrity and authenticity in the supply chain.
# Generate a key pair for signing
cosign generate-key-pair
# Sign an image in the registry
cosign sign --key cosign.key \
123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest
# Sign using keyless signing with Sigstore (OIDC-based)
cosign sign --yes \
123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest
# Verify image signature
cosign verify --key cosign.pub \
123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest
# Verify keyless signature
cosign verify \
--certificate-identity developer@company.com \
--certificate-oidc-issuer https://accounts.google.com \
123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest
# Add attestation with scan results
cosign attest --predicate trivy-results.json \
--key cosign.key \
123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest
Step 5: Configure Registry-Level Security Controls
Set up registry-specific security features for ECR, ACR, and GCR.
# AWS ECR: Enable image scanning on push
aws ecr put-image-scanning-configuration \
--repository-name myapp \
--image-scanning-configuration scanOnPush=true
# ECR: Set image tag immutability (prevent tag overwrites)
aws ecr put-image-tag-mutability \
…
常见问题
什么是“容器镜像”?
它们是打包好的文件,里面包含程序运行所需的一切,比如代码和配置。
什么是“安全漏洞”?
这些是可能被恶意人员利用,从而引发问题的弱点或缺陷。
什么是“镜像签名”?
它类似于数字签名,可以确保镜像在由可信来源创建后没有被修改过。
详情
作者的原始描述
Secures container registry images (ECR, ACR, GCR, Docker Hub) by scanning with Trivy and Grype, signing with Cosign and Sigstore, configuring registry access controls, and building CI/CD pipelines that block unscanned or unsigned images. Use when establishing registry security controls or enforcing scan/signature checks before image promotion. '
热度
- GitHub 星标
- 35k
- 排名
- #8368
- 许可证
- Apache-2.0
- 更新时间
- 2026/8/31
评论
- …
同一仓库的更多技能
abusing-dpapi-for-credential-access
35k为你的 AI 智能体提供针对特定任务的现成指令,让它完成得更好、更快。
abusing-shadow-credentials-for-privesc
35k教你的 AI 智能体写出清晰、结构良好的文本。
achieving-cmmc-level-2-compliance
35k帮助你的智能体搭建符合 CMMC Level 2 合规要求的环境。它会落实安全要求,并管理必要的文档。
acquiring-disk-image-with-dd-and-dcfldd
35k帮助你的智能体创建硬盘的精确副本。这能确保调查过程中信息不丢失、不被篡改。