secret-scanner
APIキーやパスワードなどの機密情報がコード内に含まれていないか、ユーザーの指示に応じて自動で検出・監査するSkill。
📜 元の英語説明(参考)
This skill should be used when the user asks to "scan for secrets", "find API keys", "detect credentials", "check for hardcoded passwords", "find leaked tokens", "scan for sensitive keys", "check git history for secrets", "audit repository for credentials", or mentions secret detection, credential scanning, API key exposure, token leakage, password detection, or security key auditing.
🇯🇵 日本人クリエイター向け解説
APIキーやパスワードなどの機密情報がコード内に含まれていないか、ユーザーの指示に応じて自動で検出・監査するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] secret-scanner
シークレットスキャナー
AIエージェント向けの包括的なシークレット検出スキルです。50以上のサービスにわたるAPIキー、トークン、パスワード、プライベートキー、認証情報を検出します。エントロピーベースの検出、Git履歴スキャン、CI/CD連携が特徴です。
機能
- シークレット検出 - 200以上の正規表現パターンを使用してハードコードされたシークレットを検出します。
- エントロピー分析 - シークレットである可能性のある高エントロピー文字列を検出します。
- プロバイダー対応 - AWS、GCP、Azure、GitHub、Stripeなど、50以上のプロバイダーに対応しています。
- Git履歴スキャン - 漏洩したシークレットがないか、コミット履歴全体をスキャンします。
- ファイルタイプサポート - コード、設定ファイル、環境ファイル、JSON、YAMLなどに対応しています。
- リスクスコアリング - 深刻度と露出コンテキストに基づいて検出結果をスコアリングします。
- 誤検知フィルタリング - テストデータやサンプルに対するスマートな除外機能があります。
- 修復ガイダンス - シークレットローテーションのステップバイステップの手順を提供します。
- CI/CD連携 - プリコミットフックとGitHub Actionsに対応しています。
- 許可リストサポート - 既知の安全なパターンを設定してスキップできます。
使用方法
/secret-scanner [command] [path] [options]
コマンド
scan <path>- ファイルまたはディレクトリをスキャンしてシークレットを検出します。scan-git <path>- Git履歴をスキャンして漏洩したシークレットを検出します。audit <path>- レポート生成を含む完全なセキュリティ監査を実行します。verify <secret>- 特定の文字列がシークレットパターンに一致するかどうかを確認します。providers- サポートされているすべてのシークレットプロバイダーをリスト表示します。report- 既存の検出結果からレポートを生成します。
オプション
--format <type>- 出力形式: json, markdown, sarif (デフォルト: markdown)--output <file>- 結果をファイルに書き込みます。--severity <level>- 最小深刻度: low, medium, high, critical--include <patterns>- 含めるファイルパターン--exclude <patterns>- 除外するファイルパターン--entropy <threshold>- エントロピーしきい値 (デフォルト: 4.5)--no-entropy- エントロピーベースの検出を無効にします。--allowlist <file>- 許可リスト設定へのパス--git-depth <n>- スキャンするコミット数 (デフォルト: すべて)
ワークフロー
呼び出された場合、以下のワークフローに従います。
ステップ1: スキャンの範囲を決定する
ユーザーに以下を指定するよう求めます。
- ターゲットパス(ファイル、ディレクトリ、またはリポジトリ)
- スキャンタイプ(現在のファイル、Git履歴、またはその両方)
- エントロピーベースの検出を含めるかどうか
ステップ2: ファイルの検出
Globを使用して関連ファイルを検索します。
# ソースコード
**/*.{py,js,ts,tsx,jsx,java,go,rb,php,cs,swift,kt,rs,c,cpp,h}
# 設定
**/*.{env,json,yaml,yml,xml,toml,ini,conf,cfg,properties}
# インフラストラクチャ
**/*.{tf,tfvars,hcl,dockerfile,docker-compose*}
# シェルスクリプト
**/*.{sh,bash,zsh,ps1,bat,cmd}
# 証明書とキー
**/*.{pem,key,p12,pfx,jks,keystore}
ステップ3: パターンマッチング
references/secret-patterns.mdから検出パターンを適用します。
深刻度:Critical
# AWS アクセスキー
AKIA[0-9A-Z]{16}
# AWS シークレットキー
(?i)aws.{0,20}['"][0-9a-zA-Z/+]{40}['"]
# GitHub トークン
gh[pousr]_[A-Za-z0-9_]{36,255}
# プライベートキー
-----BEGIN (RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----
深刻度:High
# 汎用 API キー
(?i)(api[_-]?key|apikey)['"]?\s*[:=]\s*['"][a-zA-Z0-9_\-]{20,}['"]
# 汎用トークン
(?i)(token|bearer|auth)['"]?\s*[:=]\s*['"][a-zA-Z0-9_\-\.]{20,}['"]
# パスワード
(?i)(password|passwd|pwd)['"]?\s*[:=]\s*['"][^'"]{8,}['"]
ステップ4: エントロピー分析
既知のパターンに一致しない文字列について、シャノンエントロピーを計算します。
def calculate_entropy(string):
"""文字列のシャノンエントロピーを計算します。"""
from collections import Counter
import math
if not string:
return 0
counts = Counter(string)
length = len(string)
entropy = -sum(
(count / length) * math.log2(count / length)
for count in counts.values()
)
return entropy
# エントロピー > 4.5 かつ 長さ >= 20 の文字列をフラグ付けします。
ステップ5: コンテキスト分析
各潜在的なシークレットについて:
- 周囲のコンテキスト(変数名、コメント)を確認します。
- テスト/サンプルファイルではないことを確認します。
- 許可リストと照合します。
- 露出コンテキスト(公開リポジトリ、.envなど)を決定します。
ステップ6: リスクスコアの計算
references/risk-scoring.mdの式を適用します。
リスク = (機密性 × 0.40) + (露出 × 0.30) +
(検証可能性 × 0.15) + (範囲 × 0.15)
ステップ7: 出力の生成
examples/sample-finding.jsonに従って検出結果をフォーマットします。
{
"id": "S-20260204-0001",
"file": "config/settings.py",
"line": 42,
"secret_type": "aws_access_key",
"provider": "AWS",
"value_preview": "AKIA...XXXX",
"confidence": 0.98,
"risk_score": 95,
"severity": "critical",
"context": "AWS_ACCESS_KEY = 'AKIA[REDACTED]'",
"remediation": [...],
"verified": false
}
サポートされているプロバイダー
クラウドプロバイダー
| プロバイダー | シークレットタイプ | パターン数 |
|---|---|---|
| AWS | アクセスキー、シークレットキー、セッショントークン | 8 |
| GCP | APIキー、サービスアカウントキー、OAuth | 6 |
| Azure | ストレージキー、接続文字列、SASトークン | 7 |
| DigitalOcean | APIトークン、Spacesキー | 3 |
| Heroku | APIキー、OAuthトークン | 2 |
| Alibaba Cloud | アクセスキー、シークレットキー | 3 |
コードプラットフォーム
| プロバイダー | シークレットタイプ | パターン数 |
|---|---|---|
| GitHub | パーソナルアクセストークン、アプリトークン、OAuth | 5 |
| GitLab | パーソナルトークン、パイプラインアクセストークン、ランナートークン | 4 |
| Bitbucket | アプリパスワード、OAuth、リポジトリトークン | 3 |
| npm | 認証トークン、公開トークン | 2 |
| PyPI | APIトークン | 1 |
決済サービス
| プロバイダー | シークレットタイプ | パターン数 |
|---|---|---|
| Stripe | シークレットキー、公開可能キー、制限付きキー | 4 |
| PayPal | クライアントシークレット、アクセストークン | 2 |
| Square | アクセストークン、アプリケーションID | 2 |
| Braintree | アクセストークン、マーチャントID | 2 |
コミュニケーションサービス
| プロバイダー | シークレットタイプ | パターン数 |
|---|---|---|
| Twilio | アカウントSID、認証トークン、APIキー | 4 |
| SendGrid | APIキー | 2 |
| Mailchimp | APIキー | 1 |
| Slack | ボットトークン、ユーザートークン、Webhook | 4 |
| Disc |
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Secret Scanner
A comprehensive secret detection skill for AI agents. Detects API keys, tokens, passwords, private keys, and credentials across 50+ services. Features entropy-based detection, git history scanning, and CI/CD integration.
Capabilities
- Secret Detection - Find hardcoded secrets using 200+ regex patterns
- Entropy Analysis - Detect high-entropy strings that may be secrets
- Provider Coverage - AWS, GCP, Azure, GitHub, Stripe, and 50+ more
- Git History Scan - Scan entire commit history for leaked secrets
- File Type Support - Code, configs, env files, JSON, YAML, and more
- Risk Scoring - Score findings by severity and exposure context
- False Positive Filtering - Smart exclusions for test data and examples
- Remediation Guidance - Step-by-step secret rotation instructions
- CI/CD Integration - Pre-commit hooks and GitHub Actions
- Allowlist Support - Configure known-safe patterns to skip
Usage
/secret-scanner [command] [path] [options]
Commands
scan <path>- Scan files or directories for secretsscan-git <path>- Scan git history for leaked secretsaudit <path>- Full security audit with report generationverify <secret>- Check if a specific string matches secret patternsproviders- List all supported secret providersreport- Generate report from existing findings
Options
--format <type>- Output format: json, markdown, sarif (default: markdown)--output <file>- Write results to file--severity <level>- Minimum severity: low, medium, high, critical--include <patterns>- File patterns to include--exclude <patterns>- File patterns to exclude--entropy <threshold>- Entropy threshold (default: 4.5)--no-entropy- Disable entropy-based detection--allowlist <file>- Path to allowlist configuration--git-depth <n>- Number of commits to scan (default: all)
Workflow
When invoked, follow this workflow:
Step 1: Determine Scan Scope
Ask the user to specify:
- Target path (file, directory, or repository)
- Scan type (current files, git history, or both)
- Whether to include entropy-based detection
Step 2: File Discovery
Use Glob to find relevant files:
# Source code
**/*.{py,js,ts,tsx,jsx,java,go,rb,php,cs,swift,kt,rs,c,cpp,h}
# Configuration
**/*.{env,json,yaml,yml,xml,toml,ini,conf,cfg,properties}
# Infrastructure
**/*.{tf,tfvars,hcl,dockerfile,docker-compose*}
# Shell scripts
**/*.{sh,bash,zsh,ps1,bat,cmd}
# Certificates and keys
**/*.{pem,key,p12,pfx,jks,keystore}
Step 3: Pattern Matching
Apply detection patterns from references/secret-patterns.md:
Critical Severity
# AWS Access Keys
AKIA[0-9A-Z]{16}
# AWS Secret Keys
(?i)aws.{0,20}['"][0-9a-zA-Z/+]{40}['"]
# GitHub Tokens
gh[pousr]_[A-Za-z0-9_]{36,255}
# Private Keys
-----BEGIN (RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----
High Severity
# Generic API Keys
(?i)(api[_-]?key|apikey)['"]?\s*[:=]\s*['"][a-zA-Z0-9_\-]{20,}['"]
# Generic Tokens
(?i)(token|bearer|auth)['"]?\s*[:=]\s*['"][a-zA-Z0-9_\-\.]{20,}['"]
# Passwords
(?i)(password|passwd|pwd)['"]?\s*[:=]\s*['"][^'"]{8,}['"]
Step 4: Entropy Analysis
For strings not matching known patterns, calculate Shannon entropy:
def calculate_entropy(string):
"""Calculate Shannon entropy of a string."""
from collections import Counter
import math
if not string:
return 0
counts = Counter(string)
length = len(string)
entropy = -sum(
(count / length) * math.log2(count / length)
for count in counts.values()
)
return entropy
# Flag strings with entropy > 4.5 and length >= 20
Step 5: Context Analysis
For each potential secret:
- Check surrounding context (variable names, comments)
- Verify it's not in a test/example file
- Check against allowlist
- Determine exposure context (public repo, .env, etc.)
Step 6: Calculate Risk Score
Apply formula from references/risk-scoring.md:
Risk = (Sensitivity × 0.40) + (Exposure × 0.30) +
(Verifiability × 0.15) + (Scope × 0.15)
Step 7: Generate Output
Format findings following examples/sample-finding.json:
{
"id": "S-20260204-0001",
"file": "config/settings.py",
"line": 42,
"secret_type": "aws_access_key",
"provider": "AWS",
"value_preview": "AKIA...XXXX",
"confidence": 0.98,
"risk_score": 95,
"severity": "critical",
"context": "AWS_ACCESS_KEY = 'AKIA[REDACTED]'",
"remediation": [...],
"verified": false
}
Supported Providers
Cloud Providers
| Provider | Secret Types | Pattern Count |
|---|---|---|
| AWS | Access Keys, Secret Keys, Session Tokens | 8 |
| GCP | API Keys, Service Account Keys, OAuth | 6 |
| Azure | Storage Keys, Connection Strings, SAS Tokens | 7 |
| DigitalOcean | API Tokens, Spaces Keys | 3 |
| Heroku | API Keys, OAuth Tokens | 2 |
| Alibaba Cloud | Access Keys, Secret Keys | 3 |
Code Platforms
| Provider | Secret Types | Pattern Count |
|---|---|---|
| GitHub | Personal Access Tokens, App Tokens, OAuth | 5 |
| GitLab | Personal Tokens, Pipeline Tokens, Runner Tokens | 4 |
| Bitbucket | App Passwords, OAuth, Repository Tokens | 3 |
| npm | Auth Tokens, Publish Tokens | 2 |
| PyPI | API Tokens | 1 |
Payment Services
| Provider | Secret Types | Pattern Count |
|---|---|---|
| Stripe | Secret Keys, Publishable Keys, Restricted Keys | 4 |
| PayPal | Client Secrets, Access Tokens | 2 |
| Square | Access Tokens, Application IDs | 2 |
| Braintree | Access Tokens, Merchant IDs | 2 |
Communication Services
| Provider | Secret Types | Pattern Count |
|---|---|---|
| Twilio | Account SID, Auth Token, API Key | 4 |
| SendGrid | API Keys | 2 |
| Mailchimp | API Keys | 1 |
| Slack | Bot Tokens, User Tokens, Webhooks | 4 |
| Discord | Bot Tokens, Webhooks | 2 |
Database Services
| Provider | Secret Types | Pattern Count |
|---|---|---|
| MongoDB | Connection Strings | 2 |
| PostgreSQL | Connection Strings | 2 |
| MySQL | Connection Strings | 2 |
| Redis | Connection Strings, Auth Tokens | 2 |
Other Services
| Provider | Secret Types | Pattern Count |
|---|---|---|
| OpenAI | API Keys | 2 |
| Anthropic | API Keys | 1 |
| Firebase | API Keys, Admin SDK Keys | 3 |
| Cloudflare | API Keys, API Tokens | 2 |
| Datadog | API Keys, App Keys | 2 |
| New Relic | License Keys, API Keys | 2 |
| Auth0 | Client Secrets, API Tokens | 2 |
| Okta | API Tokens | 1 |
| JWT | Tokens (signature analysis) | 1 |
Full pattern list: references/secret-patterns.md
Git History Scanning
Scan Modes
- Full History - Scan all commits
- Depth Limited - Scan last N commits
- Branch Specific - Scan specific branch
- Diff Mode - Only scan changed lines
Usage
# Scan entire history
/secret-scanner scan-git ./repo
# Scan last 100 commits
/secret-scanner scan-git ./repo --git-depth 100
# Scan specific branch
/secret-scanner scan-git ./repo --branch feature/auth
Git-Specific Findings
{
"commit": "abc123",
"author": "developer@example.com",
"date": "2026-01-15T10:30:00Z",
"message": "Add API configuration",
"file": "config.py",
"secret_type": "stripe_secret_key",
"still_present": false,
"removed_in": "def456"
}
Entropy-Based Detection
How It Works
- Extract string literals and values from files
- Calculate Shannon entropy for each string
- Flag high-entropy strings (> 4.5) that are:
- At least 20 characters long
- Contain mixed character classes
- In security-sensitive contexts
Entropy Thresholds
| Threshold | Detection Level | False Positive Rate |
|---|---|---|
| 3.5 | Aggressive | High |
| 4.0 | Moderate | Medium |
| 4.5 | Balanced (default) | Low |
| 5.0 | Conservative | Very Low |
Context Boosting
Entropy findings are boosted if found in:
- Variable names containing: key, secret, token, password, auth
- Files:
.env,secrets.*,credentials.* - Config sections:
[credentials],[auth]
False Positive Handling
Built-in Exclusions
- Test Files -
*_test.*,*_spec.*,test_*.*,__tests__/* - Example Files -
example.*,sample.*,demo.* - Documentation -
*.md,*.rst,docs/* - Mock Data - Files containing "mock", "fake", "dummy"
- Known Safe Patterns:
AKIAIOSFODNN7EXAMPLE(AWS example key)sk_test_*(Stripe test keys)pk_test_*(Stripe test publishable keys)xoxb-PLACEHOLDER-EXAMPLE-TOKEN(Slack example)
Allowlist Configuration
Create .secret-scanner-allowlist.yaml:
# Allowlist configuration
patterns:
# Regex patterns to ignore
- "EXAMPLE_[A-Z_]+"
- "test_api_key_\\d+"
paths:
# Files/directories to skip
- "test/"
- "fixtures/"
- "*.example"
hashes:
# SHA256 hashes of known false positives
- "abc123..."
comments:
# Inline comments that suppress warnings
- "# secret-scanner:ignore"
- "// nosecret"
Risk Scoring
Severity Levels
| Score | Severity | Response | Examples |
|---|---|---|---|
| 90-100 | Critical | Immediate | AWS keys, private keys, prod DB passwords |
| 70-89 | High | Within 4 hours | API keys, OAuth tokens, service accounts |
| 50-69 | Medium | Within 24 hours | Test API keys, internal tokens |
| 25-49 | Low | Within 1 week | Entropy matches, partial credentials |
| 0-24 | Info | Review | Possible false positives |
Factor Weights
- Sensitivity (40%): Type of secret and potential damage
- Exposure (30%): Where the secret was found
- Verifiability (15%): Can the secret be validated as real
- Scope (15%): Blast radius if exploited
Full methodology: references/risk-scoring.md
Remediation Workflow
Step 1: Immediate Actions
- Revoke the secret - Invalidate immediately in provider console
- Rotate credentials - Generate new secret
- Update applications - Deploy new credentials
- Audit access logs - Check for unauthorized usage
Step 2: Clean Up
- Remove from code - Delete the hardcoded secret
- Clean git history - Use BFG or git filter-branch
- Force push - Update all branches
- Invalidate caches - Clear CI/CD caches
Step 3: Prevention
- Add to .gitignore - Prevent future commits
- Install pre-commit hook - Block commits with secrets
- Use secrets manager - AWS Secrets Manager, HashiCorp Vault
- Environment variables - Store secrets in environment
Provider-specific instructions: references/remediation.md
CI/CD Integration
Pre-Commit Hook
# Install the pre-commit hook
cp scripts/pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
Pre-commit Framework
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: secret-scanner
name: Secret Scanner
entry: python scripts/detect-secrets.py
language: python
types: [file]
pass_filenames: true
GitHub Actions
# .github/workflows/secret-scan.yml
name: Secret Scan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for git scanning
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run Secret Scan
run: |
python scripts/detect-secrets.py . --format sarif --output results.sarif
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
Environment Variables
# Configure behavior
export SECRET_SCANNER_SEVERITY=high # Minimum severity to report
export SECRET_SCANNER_ENTROPY=4.5 # Entropy threshold
export SECRET_SCANNER_BLOCK=true # Block on findings
export SECRET_SCANNER_ALLOWLIST=.secret-scanner-allowlist.yaml
Output Formats
JSON (findings.json)
Structured array with all findings and metadata.
Markdown (report.md)
Human-readable report with:
- Executive summary
- Findings by severity
- Provider breakdown
- Remediation checklist
SARIF
Static Analysis Results Interchange Format for GitHub Security tab integration.
Security Guardrails
- Never output full secrets - Show only prefix/suffix with masking
- Secure temporary files - Use scratchpad, clean up after
- No secret logging - Redact from all log output
- Verification is optional - Don't auto-verify against live APIs
- Respect allowlists - Honor configured exclusions
References
references/secret-patterns.md- All detection patternsreferences/provider-patterns.md- Provider-specific patternsreferences/entropy-detection.md- Entropy analysis methodologyreferences/risk-scoring.md- Risk scoring methodologyreferences/remediation.md- Secret rotation guidesreferences/allowlist-config.md- Allowlist configuration
Examples
examples/sample-finding.json- Example finding outputexamples/sample-report.md- Example audit reportexamples/allowlist.yaml- Example allowlist configuration
Scripts
scripts/detect-secrets.py- Main secret detection scriptscripts/scan-git-history.py- Git history scannerscripts/entropy-analyzer.py- Entropy-based detectionscripts/generate-report.py- Report generationscripts/pre-commit-hook.sh- Git pre-commit hook