claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

🔒remediating-with-aws-security-agent

説明

AWS Security Agent のファインディング(ペネトレーションテストおよびコードレビュー)を取得し、修正対応を推進します。 次のような場合に使用: ユーザーが Security Agent、セキュリティファインディング、ペンテスト/ペネトレーションテストの結果、コードレビューのファインディング、AWS アカウントで発見された脆弱性、「セキュリティスキャンで何が見つかったか」、セキュリティリスクの修正対応やトリアージ、または報告された脆弱性の修正開始について言及している場合。 サービス名が明示されていない場合でも起動してください。 「セキュリティファインディングを取得して」「どんな脆弱性がある?」「ペンテスト結果を直そう」「セキュリティレポートをトリアージして」といったフレーズでもトリガーします。 このスキルは、スキャンを検出し、ファインディングを `.gitignore` 済みのローカルディレクトリにエクスポートし(機密性の高い攻撃手法の詳細がコミットされないよう保護)、優先度付きのトリアージサマリーを生成したうえで、最もリスクの高い問題の修正に着手するよう提案します。

原文を表示

Pull AWS Security Agent findings (penetration tests and code reviews) and drive remediation. Use this whenever the user mentions Security Agent, security findings, pentest or penetration test results, code review findings, vulnerabilities found in their AWS account, "what did the security scan find", remediating or triaging security risks, or wants to start fixing reported vulnerabilities — even if they don't name the service explicitly. Trigger it for phrases like "get my security findings", "what vulnerabilities do we have", "let's fix the pentest results", or "triage the security report". The skill discovers scans, exports findings to a gitignored local directory (so sensitive exploit detail is never committed), produces a prioritized triage summary, and offers to start fixing the highest-risk issues.

ユースケース

  • セキュリティファインディングを取得するとき
  • ペネトレーションテスト結果を確認するとき
  • コードレビューの脆弱性を修正するとき
  • セキュリティリスクをトリアージするとき
  • 報告された脆弱性の対応を開始するとき

本文(日本語訳)

セキュリティエージェント 修復スキル

AWS Security Agent は、顧客のアプリケーションに対してオンデマンドの侵入テストおよびコードレビューを実行し、検証済みのセキュリティリスクを報告するフロンティア Agentです。このスキルは、「AWS のどこかに検出結果がある」という状態から「最も重要な問題を積極的に修正している」という状態へと導きます。その際、機密性の高いエクスプロイトの詳細をソースコントロールの外に保ちます。

フローは順序が重要な4つのステージで構成されています:

  1. Discover(検出) — どのスキャンが存在し、アカウントがどのように構成されているかを確認する(ライブ、読み取り専用)。
  2. Export(エクスポート) — 検出結果をローカルの gitignore 対象ディレクトリに書き出す。
  3. Triage(トリアージ) — 検出結果を優先順位付きで人間が読める形のプランに整理する。
  4. Remediate(修復) — 最もリスクの高い問題の修正を提案する。

順序とガードレールが重要な理由

検出結果には、動作する攻撃スクリプト、再現手順、ファイルパス、場合によっては漏洩したシークレットや環境の詳細が含まれています。 これが Git リポジトリに入ると、顧客が誤って自分の本番システムへのステップバイステップのエクスプロイトをコミット・公開してしまう可能性があります。 そのため、絶対に守るべきルールは: 検出結果は .security-agent/ にのみ書き込み、何かを書き込む前にそのパスを gitignore に追加する、というものです。


ステージ 1: スキャンの検出(ライブ、読み取り専用)

アカウントに何があるかを確認します。すべてのコマンドは読み取り専用の list-* 操作です。

AWS Security Agent はデータを階層構造で管理しています — 上から順に掘り下げていきます:

Application(アカウント + リージョン)
└── Agent Space(設計レビュー、コードレビュー、侵入テストのワークスペース)
    ├── 侵入テスト → Pentest ジョブ → 検出結果
    └── コードレビュー → Code review ジョブ → 検出結果

以下を実行して現状を把握し、ユーザーに存在するものを示します:

aws securityagent list-agent-spaces
aws securityagent list-pentests          --agent-space-id <as-...>
aws securityagent list-code-reviews      --agent-space-id <as-...>
aws securityagent list-pentest-jobs-for-pentest         --agent-space-id <as-...> --pentest-id <pt-...>
aws securityagent list-code-review-jobs-for-code-review --agent-space-id <as-...> --code-review-id <cr-...>

ジョブの statusIN_PROGRESSSTOPPINGSTOPPEDFAILEDCOMPLETED のいずれかです。 安定した完全な検出結果セットを持つのは COMPLETED ジョブのみです。

コードベースとスキャンの照合、そして確認

Agent Space、侵入テスト、コードレビューは、対象アプリケーションの名前が付けられています。 生のリストからユーザーに選ばせる前に、このリポジトリに対応するスキャンがどれかを推測してください — ユーザーはある理由でコードベースを操作しており、関連する検出結果はほぼ常に目の前のアプリのものです。

コストが低く情報量の多い手がかりからアプリの正体を推定します:

  • リポジトリ名またはルートディレクトリ名、および Git リモートの URL(git remote -v)。
  • プロジェクトのマニフェストファイルと、その name / descriptionpackage.jsonpyproject.toml*.csprojgo.modCargo.toml)。
  • README のタイトル、製品/ステアリングドキュメント、明らかな製品名や企業名。
  • スキャンタイトルと一致する特徴的なフレームワークやドメイン。

これらの手がかりを Agent Space / スキャン名と照合します(大文字・小文字の区別なし、部分一致・ファジーマッチを許容)。 その後、エクスポートの前に必ず確認を取ってください — 最善の推測とその根拠を提示し、ユーザーが修正できるようにします:

「このリポジトリは <signal> から判断して <product> と思われます。これは <name> Agent Space に一致します。これを使用しますか?それとも別のものを選択しますか? [他の Agent Space 名: ...]」

合理的な確信を持って一致するものがない場合は、その旨を明確に伝え、誤った推測を強行せずに全リストを表示してください。 ユーザーの確認なしに推測のスキャンからエクスポートしないでください。


ステージ 2: .security-agent/ への検出結果のエクスポート(gitignore 対象)

AWS CLI コマンドを使って検出結果を取得します。 検出結果には動作する攻撃スクリプト、再現手順、場合によっては漏洩したシークレットが含まれるため、すべてをリポジトリ内の .security-agent/ に書き込みます — チャットや標準出力には出力しません。

1. 何かを取得する前に出力ディレクトリを保護する

mkdir -p .security-agent
echo '*' > .security-agent/.gitignore

2. 最新の COMPLETED ジョブを特定する

ステージ 1 で agentSpaceId と pentest / code-review の ID は取得済みのはずです。 選択したスキャンのジョブを一覧表示します:

# Pentest ジョブ:
aws securityagent list-pentest-jobs-for-pentest \
  --agent-space-id <as-...> --pentest-id <pt-...>

# Code review ジョブ:
aws securityagent list-code-review-jobs-for-code-review \
  --agent-space-id <as-...> --code-review-id <cr-...>

前のレスポンスの --next-token を渡してページネーションし、なくなるまで繰り返します。 ジョブのサマリーを status == "COMPLETED" でフィルタリングします。 COMPLETED のジョブが1件もなければ、処理を停止してユーザーに「完了したジョブが見つかりません。ジョブの完了を待つか、ジョブのステータスを確認してください。」と伝えます。 COMPLETED ジョブがある場合は、createdAt タイムスタンプが最も新しいものを選択します。

3. 検出結果のサマリーを一覧表示し、信頼度でフィルタリングする

# Pentest の検出結果:
aws securityagent list-findings \
  --agent-space-id <as-...> --pentest-job-id <pj-...>

# Code review の検出結果:
aws securityagent list-findings \
  --agent-space-id <as-...> --code-review-job-id <cj-...>

--next-token がなくなるまでページネーションを続けます。 信頼度の値は弱い順に: FALSE_POSITIVEUNCONFIRMEDLOWMEDIUMHIGHデフォルトでは HIGHMEDIUM のみを保持します。 ユーザーが明示的に要求した場合にのみ範囲を広げます。

4. 25件単位でバッチ取得する

batch-get-findings は1回の呼び出しで最大25件の ID を受け付けます。 フィルタリング後の検出結果 ID を25件ずつのグループに分割します:

aws securityagent batch-get-findings \
  --agent-space-id <as-...> \
  --finding-ids <fid-1> <fid-2> ... <fid-25>

ステージ 3 のトリアージで区別できるよう、返された各検出結果にソース(pentest または code-review)のタグを付けてから書き込みます。

5. 検出結果を .security-agent/ に書き込む

検出結果をジョブ ID でグルーピングします。 各ジョブについて、API が返すすべてのフィールド(findingId、name、description、riskLevel、riskType、confidence、status、codeLocations、remediationCode、その他すべてのフィールド)を含む完全な Markdown レポートを .security-agent/findings_<jobId>.md に書き込みます。 フィールドを省略しないでください。

エッジケース

  • Agent Space、スキャン、または COMPLETED ジョブが存在しない場合 — リトライせずに処理を停止し、ユーザーにその旨を伝えます。
  • 認証情報またはサービスが利用できない場合aws sts get-caller-identity で確認し、リージョンを確認します(デフォルトは us-east-1;Security Agent はリージョナルサービスです)。
  • 検出結果の内容をチャットに貼り付けないでください — 短いタイトルと件数以上の情報は貼り付けません。詳細は gitignore 対象ファイルに属します。

ステージ 3: 優先順位付きプランへのトリアージ

修復に使える時間は有限であり、CRITICAL の未認証 RCE は LOW の情報提供レベルの検出結果より常に優先されるため、リスクでランク付けします。 .security-agent/ からエクスポートした findings_*.md ファイルを読み込み、決定論的にソートします。

ランキングルール

以下の複合キーで昇順にソートします(値が小さいほど緊急度が高い):

  1. リスクレベル(この順序で): CRITICAL(0)→ HIGH(1)→ MEDIUM(2)→ LOW(3)→ INFORMATIONAL(4)→ UNKNOWN / 欠損(5)

  2. リスクスコア(高い順): riskScore は pentest の検出結果では数値文字列(例: "10.0")ですが、code-review の検出結果では存在しないことが多いです — 欠損の場合は同じレベルのスコア付き検出結果の後に来るよう、最小値として扱います。

  3. 信頼度(この順序で): HIGH(0)→ MEDIUM(1)→ LOW(2)→ UNCONFIRMED(3)→ FALSE_POSITIVE(4)

また、すべての検出結果にわたる重大度の件数サマリー(例: 2 CRITICAL · 5 HIGH · 3 MEDIUM)をレポートのヘッダー用に算出します。

コードの場所の取得

各検出結果について、単一の短い location 文字列を導出します:

  • filePath が設定されている場合は、そのまま使用します。
  • それ以外の場合は codeLocations[0] を取得します。スキャナーのサンドボックスプレフィックスを filePath から除去し(そのマーカーまでのすべてを含む)、パスをリポジトリ相対にします。マーカーが存在しない場合はベース名にフォールバックします。lineStart がある場合は :<lineStart> を追加します。
  • どちらも利用できない場合(一部の pentest 検出結果に典型的)は空白のままにし、代わりに影響行で対象のエンドポイントや攻撃チェーンを説明します。

サマリーフォーマット

ユーザー向けのコンパクトなサマリーを作成します:

## Security Agent トリアージ — <Agent Space 名>

<N> 件の検出結果をエクスポート(pentest: <P> 件、code review: <C> 件)· 信頼度: <レベル> · 重大度: <件数>

### 優先順位
1. [CRITICAL · スコア 10.0 · HIGH 信頼度] <検出結果名>
   - タイプ: <riskType> · ソース: <pentest|code-review>
   - 場所: <ファイル:行 またはエンドポイント(存在する場合)>
   - 影響: <平易な言葉での1行サマリー>
2. [HIGH · ...] ...

### 推奨修復順序
<短い根拠: 何を最初に修正すべきか、その理由 — 例: 「1 と 3 はどちらもインターネット公開エンドポイントへの未認証 RCE です。stored-XSS の問題より先にこれらを修正してください。」>

検出結果が10件を超える場合は、上位 N 件を詳細に表示し、残りは重大度ごとの件数でサマリーとして末尾に記載します。

チャットから除外すべきもの

description

原文(English)を表示

Security Agent Remediation

AWS Security Agent is a frontier agent that runs on-demand penetration tests and code reviews against a customer's applications and reports verified security risks. This skill takes you from "I have findings somewhere in AWS" to "I'm actively fixing the most important ones," while keeping the sensitive exploit detail out of source control.

The flow has four stages, and they matter in order:

  1. Discover which scans exist and how the account is configured (live, read-only).
  2. Export the findings to a local gitignored directory.
  3. Triage the findings into a prioritized, human-readable plan.
  4. Remediate by offering to fix the highest-risk issues.

Why the ordering and the guardrails matter

Findings contain working attack scripts, reproduction steps, file paths, and sometimes leaked secrets or environment details. If that lands in a Git repo, a customer can accidentally commit and publish a step-by-step exploit for their own production system. So the non-negotiable rule is: findings are written only to .security-agent/, and that path is gitignored before anything is written.

Stage 1: Discover scans (live, read-only)

Find out what the account has. All commands are read-only list-* operations.

AWS Security Agent organizes data as a hierarchy — work down it:

Application (account + Region)
└── Agent Space        (workspace for design review, code review, and pentests)
    ├── Penetration test → Pentest job → Findings
    └── Code review      → Code review job → Findings

Run these to orient yourself and show the user what exists:

aws securityagent list-agent-spaces
aws securityagent list-pentests          --agent-space-id <as-...>
aws securityagent list-code-reviews      --agent-space-id <as-...>
aws securityagent list-pentest-jobs-for-pentest         --agent-space-id <as-...> --pentest-id <pt-...>
aws securityagent list-code-review-jobs-for-code-review --agent-space-id <as-...> --code-review-id <cr-...>

Job status is one of IN_PROGRESS, STOPPING, STOPPED, FAILED, COMPLETED. Only COMPLETED jobs have a stable, full set of findings.

Match the codebase to a scan, then confirm

Agent spaces, pentests, and code reviews are named after the application they target. Before asking the user to pick from a raw list, make an informed guess about which scan corresponds to this repository — the user is working in a codebase for a reason, and the relevant findings are almost always for the app in front of them.

Infer the app identity from the workspace using cheap, high-signal sources:

  • The repository / root directory name and the Git remote URL (git remote -v).
  • Project manifests and their name/description (package.json, pyproject.toml, *.csproj, go.mod, Cargo.toml).
  • README titles, product/steering docs, and any obvious product or company name.
  • Distinctive frameworks or domains that match a scan title.

Compare those signals against the agent space / scan names (case-insensitive, allow partial and fuzzy matches). Then always confirm before exporting — present your best guess and your reasoning, and let the user correct it:

"This repo looks like <product> (from <signal>), which matches the <name> agent space. Use that, or pick another? [Other Agent Space names, ...]"

If nothing matches with reasonable confidence, say so plainly and show the full list rather than forcing a wrong guess. Never export from a guessed scan without the user's confirmation.

Stage 2: Export findings to .security-agent/ (gitignored)

Pull findings using AWS CLI commands. Write everything into .security-agent/ in the repo — never to chat or stdout — because findings include working attack scripts, reproduction steps, and sometimes leaked secrets.

1. Lock down the output directory before pulling anything

mkdir -p .security-agent
echo '*' > .security-agent/.gitignore

2. Resolve the latest COMPLETED job

You should already have the agentSpaceId and the pentest/code-review id from Stage 1. List jobs for the chosen scan:

# Pentest jobs:
aws securityagent list-pentest-jobs-for-pentest \
  --agent-space-id <as-...> --pentest-id <pt-...>

# Code review jobs:
aws securityagent list-code-review-jobs-for-code-review \
  --agent-space-id <as-...> --code-review-id <cr-...>

Paginate by passing --next-token from the previous response until absent. Filter the job summaries to status == "COMPLETED". If none are COMPLETED, stop and tell the user "No completed jobs found. Please wait for a job to complete or check job statuses." Otherwise, pick the COMPLETED job with the greatest createdAt timestamp.

3. List finding summaries and filter by confidence

# Pentest findings:
aws securityagent list-findings \
  --agent-space-id <as-...> --pentest-job-id <pj-...>

# Code review findings:
aws securityagent list-findings \
  --agent-space-id <as-...> --code-review-job-id <cj-...>

Paginate on --next-token until exhausted. Confidence values from weakest to strongest: FALSE_POSITIVE, UNCONFIRMED, LOW, MEDIUM, HIGH. Keep only HIGH and MEDIUM by default. Widen only when the user explicitly asks.

4. Fetch full detail in batches of 25

batch-get-findings accepts at most 25 ids per call. Chunk the filtered finding ids into groups of 25:

aws securityagent batch-get-findings \
  --agent-space-id <as-...> \
  --finding-ids <fid-1> <fid-2> ... <fid-25>

Tag each returned finding with its source (pentest or code-review) before writing, so triage in Stage 3 can tell them apart.

5. Write findings into .security-agent/

Group findings by job id. For each job, write a full markdown report to .security-agent/findings_<jobId>.md with ALL fields returned by the API (findingId, name, description, riskLevel, riskType, confidence, status, codeLocations, remediationCode, and any other fields). Do not leave off any fields.

Edge cases

  • No agent space, scan, or COMPLETED job — stop and surface that to the user rather than retrying.
  • Credentials or service unavailable — confirm with aws sts get-caller-identity and check the Region (default us-east-1; Security Agent is regional).
  • Don't paste finding contents into chat beyond short titles and counts. The detail belongs in the gitignored files.

Stage 3: Triage into a prioritized plan

Rank by risk, because remediation time is finite and a CRITICAL unauthenticated RCE outranks a LOW informational finding every time. Read the exported findings_*.md files from .security-agent/ and sort them deterministically.

Ranking rules

Sort ascending by this composite key (lower wins, i.e. more urgent first):

  1. Risk level, in this order: CRITICAL (0) → HIGH (1) → MEDIUM (2) → LOW (3) → INFORMATIONAL (4) → UNKNOWN / missing (5).
  2. Risk score, highest first. riskScore is a numeric string on pentest findings (e.g. "10.0"), often absent on code-review findings — treat missing as the lowest possible score so it sorts after scored findings of the same level.
  3. Confidence, in this order: HIGH (0) → MEDIUM (1) → LOW (2) → UNCONFIRMED (3) → FALSE_POSITIVE (4).

Also compute a severity-count summary across all findings (e.g. 2 CRITICAL · 5 HIGH · 3 MEDIUM) for the header of the report.

Pulling the code location

For each finding, derive a single short location string:

  • If filePath is set, use it as-is.
  • Otherwise, take codeLocations[0]. Strip the scanner's sandbox prefix from filePath (everything up to and including that marker) so the path is repo-relative; if that marker isn't present, fall back to the basename. Append :<lineStart> when present.
  • If neither is available (typical for some pentest findings), leave it blank and describe the affected endpoint or attack chain in the impact line instead.

Summary format

Write a compact summary for the user:

## Security Agent triage — <agent space name>

<N> findings exported (<P pentest, C code review>) · confidence: <levels> · severity: <counts>

### Priority order
1. [CRITICAL · score 10.0 · HIGH confidence] <finding name>
   - Type: <riskType> · Source: <pentest|code-review>
   - Where: <file:line or endpoint, if present>
   - Impact: <one-line plain-language summary>
2. [HIGH · ...] ...

### Recommended remediation order
<short rationale: which to fix first and why — e.g. "1 and 3 are both
unauthenticated RCE on internet-facing endpoints; fix those before the
stored-XSS issues.">

If more than ~10 findings, show the top N in detail and summarize the rest as a count by severity at the bottom.

What to keep out of chat

The full description, reasoning, and attackScript stay in the gitignored files — they contain working exploit detail. In the chat summary keep impact lines to one line each, in plain language. Code-review findings usually carry a filePath/location and a suggestedFix; call those out since they map directly to repo changes. Pentest findings describe endpoints and attack chains; map them to the responsible code where you can. Look for findings that corroborate each other (a pentest and a code review flagging the same root cause) — those are strong signals for what to fix first.

Stage 4: Offer to remediate

After presenting the triage, offer to start fixing — don't silently begin editing code.

Ask the user something like: "Want me to start fixing the top finding(s)? I'd recommend starting with #1 (<name>)." If they agree, work top-down by priority:

  1. Read the finding detail from the gitignored export file (location, description, suggested fix).
  2. Open the affected file and apply the fix via the editor.
  3. Report one line per fix: "Fixed {name} in {filePath}:{lineStart}."

If the user wants to handle several findings, fix one at a time (or one cluster of related findings) so each change stays reviewable, and proceed in the priority order from Stage 3.

Notes and edge cases

  • No completed jobs: a scan may still be IN_PROGRESS. Tell the user; offer to re-check later rather than exporting a partial job.
  • Re-running: each run overwrites the files for that job id. The directory is safe to delete; it only holds exported copies, not source-of-truth data.
  • Multiple accounts/Regions: findings are Region-scoped. If the user expected results and got none, confirm the region matches where Security Agent is configured.
  • Data handling: treat exported findings as sensitive. They are copies of verified exploits against the user's own systems.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。