jpskill.com
🛠️ 開発・MCP コミュニティ

cosign

Cosignは、コンテナイメージなどの署名・検証・メタデータ付与を支援するSigstoreツールで、CI/CDでの署名、デプロイ前の検証、SBOMや脆弱性スキャン結果の添付を通じて、サプライチェーンのセキュリティ実装を支援するSkill。

📜 元の英語説明(参考)

Expert guidance for Cosign, the Sigstore tool for signing, verifying, and attaching metadata to container images and other OCI artifacts. Helps developers implement supply chain security by signing images in CI/CD, verifying signatures before deployment, and attaching SBOMs and vulnerability scan results as attestations.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Cosignは、コンテナイメージなどの署名・検証・メタデータ付与を支援するSigstoreツールで、CI/CDでの署名、デプロイ前の検証、SBOMや脆弱性スキャン結果の添付を通じて、サプライチェーンのセキュリティ実装を支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o cosign.zip https://jpskill.com/download/14794.zip && unzip -o cosign.zip && rm cosign.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14794.zip -OutFile "$d\cosign.zip"; Expand-Archive "$d\cosign.zip" -DestinationPath $d -Force; ri "$d\cosign.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して cosign.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → cosign フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Cosign — コンテナイメージの署名と検証

概要

Cosign は、コンテナイメージやその他の OCI アーティファクトへの署名、検証、およびメタデータの添付を行うための Sigstore ツールです。開発者が CI/CD でイメージに署名し、デプロイ前に署名を検証し、SBOM や脆弱性スキャンの結果をアテステーションとして添付することで、サプライチェーンのセキュリティを実装するのに役立ちます。

手順

イメージの署名と検証

# インストール
brew install cosign

# キーペアの生成
cosign generate-key-pair
# cosign.key (秘密鍵) と cosign.pub (公開鍵) が作成されます

# ビルド後のイメージへの署名
docker build -t myregistry.com/myapp:v1.2.3 .
docker push myregistry.com/myapp:v1.2.3
cosign sign --key cosign.key myregistry.com/myapp:v1.2.3

# デプロイ前の検証
cosign verify --key cosign.pub myregistry.com/myapp:v1.2.3

# Sigstore を使用したキーレス署名 (キー管理不要!)
# OIDC アイデンティティ (GitHub Actions、Google など) を使用
cosign sign myregistry.com/myapp:v1.2.3
# OIDC ログインのためにブラウザを開き、一時的なキーで署名し、
# Rekor 透明性ログに署名を記録します

# キーレス検証
cosign verify \
  --certificate-identity=user@example.com \
  --certificate-oidc-issuer=https://accounts.google.com \
  myregistry.com/myapp:v1.2.3

CI/CD 統合

# .github/workflows/build.yml — CI でのイメージへの署名
jobs:
  build-and-sign:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write                   # キーレス署名に必要
      packages: write
    steps:
      - uses: actions/checkout@v4

      - name: ビルドとプッシュ
        run: |
          docker build -t ghcr.io/${{ github.repository }}:${{ github.sha }} .
          docker push ghcr.io/${{ github.repository }}:${{ github.sha }}

      - name: Cosign のインストール
        uses: sigstore/cosign-installer@v3

      - name: イメージへの署名 (キーレス)
        run: |
          cosign sign \
            --yes \
            ghcr.io/${{ github.repository }}:${{ github.sha }}
        env:
          COSIGN_EXPERIMENTAL: 1

      - name: SBOM の添付
        run: |
          # syft で SBOM を生成
          syft ghcr.io/${{ github.repository }}:${{ github.sha }} -o spdx-json > sbom.spdx.json

          # SBOM をアテステーションとして添付
          cosign attest \
            --yes \
            --predicate sbom.spdx.json \
            --type spdxjson \
            ghcr.io/${{ github.repository }}:${{ github.sha }}

      - name: 脆弱性スキャンの添付
        run: |
          # grype でスキャン
          grype ghcr.io/${{ github.repository }}:${{ github.sha }} -o json > vuln-scan.json

          # スキャン結果の添付
          cosign attest \
            --yes \
            --predicate vuln-scan.json \
            --type vuln \
            ghcr.io/${{ github.repository }}:${{ github.sha }}

Kubernetes での検証 (Kyverno ポリシー)

# Kubernetes ポリシー: 署名されたイメージのみをデプロイ
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: verify-image-signatures
spec:
  validationFailureAction: Enforce
  background: false
  rules:
    - name: verify-cosign-signature
      match:
        any:
          - resources:
              kinds: ["Pod"]
      verifyImages:
        - imageReferences:
            - "ghcr.io/myorg/*"
          attestors:
            - entries:
                - keyless:
                    subject: "https://github.com/myorg/*"
                    issuer: "https://token.actions.githubusercontent.com"
                    rekor:
                      url: "https://rekor.sigstore.dev"

アテステーション

# ビルドの来歴 (SLSA) のアテスト
cosign attest \
  --yes \
  --predicate provenance.json \
  --type slsaprovenance \
  myregistry.com/myapp:v1.2.3

# アテステーションの検証
cosign verify-attestation \
  --type spdxjson \
  --certificate-identity-regexp=".*@myorg.com" \
  --certificate-oidc-issuer=https://accounts.google.com \
  myregistry.com/myapp:v1.2.3

# 添付された SBOM のダウンロードと検査
cosign download attestation myregistry.com/myapp:v1.2.3 | jq -r '.payload' | base64 -d | jq .

インストール

brew install cosign
# または: go install github.com/sigstore/cosign/v2/cmd/cosign@latest
# または: https://github.com/sigstore/cosign/releases からダウンロード

例 1: マイクロサービスプロジェクトのための Cosign のセットアップ

ユーザーリクエスト:

Node.js API と React フロントエンドを Docker で実行しています。監視/デプロイのために Cosign をセットアップしてください。

エージェントは、# Install のようなパターンに基づいて必要な構成ファイルを作成し、既存の Docker セットアップとの統合をセットアップし、Node.js + React スタックに適したデフォルトを構成し、すべてが機能していることを確認するための検証コマンドを提供します。

例 2: ci/cd 統合の問題のトラブルシューティング

ユーザーリクエスト:

Cosign が ci/cd 統合でエラーを表示しています。ログは次のとおりです: [error output]

エージェントはエラー出力を分析し、一般的な Cosign の問題との相互参照によって根本原因を特定し、修正 (構成の更新、リソース制限の調整、または構文の修正) を適用し、適切なヘルスチェックで解決を検証します。

ガイドライン

  1. CI でのキーレス署名 — GitHub Actions で Sigstore のキーレス署名を使用します。キー管理は不要で、署名は OIDC アイデンティティに関連付けられます。
  2. すべてのイメージに署名 — CI/CD で署名し、デプロイ前に検証します。署名されていないイメージが本番環境に到達してはなりません。
  3. SBOM の添付 — すべてのビルドで SBOM を生成して添付します。コンプライアンス (大統領令 14028) と脆弱性追跡に必要です。
  4. アドミッションコントールでの検証 — Kyverno または OPA を使用して、Kubernetes アドミッションレベルで署名検証を強制します。
  5. Rekor 透明性ログ — キーレス署名は Rekor に記録されます。誰がいつ何に署名したかの不変の監査証跡を提供します。
  6. 来歴のアテステーション — SLSA 来歴アテステーションを添付します。イメージがどこでどのように構築されたかを証明します。
  7. ダイジェストによる固定 — SHA256 ダイジェストでイメージを参照し、
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Cosign — Container Image Signing and Verification

Overview

Cosign, the Sigstore tool for signing, verifying, and attaching metadata to container images and other OCI artifacts. Helps developers implement supply chain security by signing images in CI/CD, verifying signatures before deployment, and attaching SBOMs and vulnerability scan results as attestations.

Instructions

Sign and Verify Images

# Install
brew install cosign

# Generate a keypair
cosign generate-key-pair
# Creates cosign.key (private) and cosign.pub (public)

# Sign an image after building
docker build -t myregistry.com/myapp:v1.2.3 .
docker push myregistry.com/myapp:v1.2.3
cosign sign --key cosign.key myregistry.com/myapp:v1.2.3

# Verify before deploying
cosign verify --key cosign.pub myregistry.com/myapp:v1.2.3

# Keyless signing with Sigstore (no key management!)
# Uses OIDC identity (GitHub Actions, Google, etc.)
cosign sign myregistry.com/myapp:v1.2.3
# Opens browser for OIDC login, signs with ephemeral key,
# records signature in Rekor transparency log

# Keyless verification
cosign verify \
  --certificate-identity=user@example.com \
  --certificate-oidc-issuer=https://accounts.google.com \
  myregistry.com/myapp:v1.2.3

CI/CD Integration

# .github/workflows/build.yml — Sign images in CI
jobs:
  build-and-sign:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write                   # Required for keyless signing
      packages: write
    steps:
      - uses: actions/checkout@v4

      - name: Build and push
        run: |
          docker build -t ghcr.io/${{ github.repository }}:${{ github.sha }} .
          docker push ghcr.io/${{ github.repository }}:${{ github.sha }}

      - name: Install Cosign
        uses: sigstore/cosign-installer@v3

      - name: Sign image (keyless)
        run: |
          cosign sign \
            --yes \
            ghcr.io/${{ github.repository }}:${{ github.sha }}
        env:
          COSIGN_EXPERIMENTAL: 1

      - name: Attach SBOM
        run: |
          # Generate SBOM with syft
          syft ghcr.io/${{ github.repository }}:${{ github.sha }} -o spdx-json > sbom.spdx.json

          # Attach SBOM as an attestation
          cosign attest \
            --yes \
            --predicate sbom.spdx.json \
            --type spdxjson \
            ghcr.io/${{ github.repository }}:${{ github.sha }}

      - name: Attach vulnerability scan
        run: |
          # Scan with grype
          grype ghcr.io/${{ github.repository }}:${{ github.sha }} -o json > vuln-scan.json

          # Attach scan results
          cosign attest \
            --yes \
            --predicate vuln-scan.json \
            --type vuln \
            ghcr.io/${{ github.repository }}:${{ github.sha }}

Verify in Kubernetes (Kyverno Policy)

# Kubernetes policy: only deploy signed images
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: verify-image-signatures
spec:
  validationFailureAction: Enforce
  background: false
  rules:
    - name: verify-cosign-signature
      match:
        any:
          - resources:
              kinds: ["Pod"]
      verifyImages:
        - imageReferences:
            - "ghcr.io/myorg/*"
          attestors:
            - entries:
                - keyless:
                    subject: "https://github.com/myorg/*"
                    issuer: "https://token.actions.githubusercontent.com"
                    rekor:
                      url: "https://rekor.sigstore.dev"

Attestations

# Attest build provenance (SLSA)
cosign attest \
  --yes \
  --predicate provenance.json \
  --type slsaprovenance \
  myregistry.com/myapp:v1.2.3

# Verify attestation
cosign verify-attestation \
  --type spdxjson \
  --certificate-identity-regexp=".*@myorg.com" \
  --certificate-oidc-issuer=https://accounts.google.com \
  myregistry.com/myapp:v1.2.3

# Download and inspect attached SBOM
cosign download attestation myregistry.com/myapp:v1.2.3 | jq -r '.payload' | base64 -d | jq .

Installation

brew install cosign
# Or: go install github.com/sigstore/cosign/v2/cmd/cosign@latest
# Or: Download from https://github.com/sigstore/cosign/releases

Examples

Example 1: Setting up Cosign for a microservices project

User request:

I have a Node.js API and a React frontend running in Docker. Set up Cosign for monitoring/deployment.

The agent creates the necessary configuration files based on patterns like # Install, sets up the integration with the existing Docker setup, configures appropriate defaults for a Node.js + React stack, and provides verification commands to confirm everything is working.

Example 2: Troubleshooting ci/cd integration issues

User request:

Cosign is showing errors in our ci/cd integration. Here are the logs: [error output]

The agent analyzes the error output, identifies the root cause by cross-referencing with common Cosign issues, applies the fix (updating configuration, adjusting resource limits, or correcting syntax), and verifies the resolution with appropriate health checks.

Guidelines

  1. Keyless signing in CI — Use Sigstore's keyless signing in GitHub Actions; no key management, signatures tied to OIDC identity
  2. Sign every image — Sign in CI/CD, verify before deployment; no unsigned image should reach production
  3. Attach SBOMs — Generate and attach SBOM with every build; required for compliance (Executive Order 14028) and vulnerability tracking
  4. Verify in admission control — Use Kyverno or OPA to enforce signature verification at the Kubernetes admission level
  5. Rekor transparency log — Keyless signatures are recorded in Rekor; provides an immutable audit trail of who signed what and when
  6. Attestations for provenance — Attach SLSA provenance attestations; prove where and how the image was built
  7. Pin by digest — Reference images by SHA256 digest, not tag; tags can be overwritten, digests are immutable
  8. Vulnerability scan attestations — Attach scan results as attestations; verify no critical CVEs before deployment