AI コード・エージェント用のセキュリティー・ガードレールの生成

AppScan on Cloud の AI チャットボットを使用して、IDE 内の開発者が使用できるようにカスタマイズされたセキュリティー・ガードレールのセットを生成します。ガードレールは、AI エージェントによって生成されたコードがアプリケーションに脆弱性をもたらさないようにします。

ガードレールを生成するには:
  1. AppScan on Cloud で、アプリケーションを開きます。
  2. 「アプリケーション」ページで、AI アシスタント・アイコン () をクリックします。
  3. 次のいずれかの操作を実行します。
    • 「Help me build a security instructions file for my IDE's LLM (IDE の LLM 用のセキュリティー・インストラクション・ファイルの作成を手伝ってください)」をクリックするか、
    • 独自のプロンプトを作成します。

      例えば、「Help me create security guardrails for my application. (アプリケーション用のセキュリティー・ガードレールの作成を手伝ってください。)」

  4. ガードレールを作成するアプリケーションが現在のアプリケーションであることを確認します。
  5. AI アシスタントで 4 つの主要な質問に答えます。
    1. 使用している言語、フレームワーク、およびランタイム・バージョンは何ですか?
    2. このアプリケーションはデータベースに接続しているか、システムレベルのコマンドを実行していますか? 「はい」の場合、どのデータベースとドライバー/ORM ですか?
    3. アプリは認証と承認をどのように処理しますか?
    4. アプリには、明示的にガードレールが必要な高リスク機能が含まれていますか?

    AI アシスタントへの回答が明確でない場合は、明確化のための質問をします。

    AI アシスタントは、マークダウン・ファイルとして保存するか、IDE 内の関連ファイルにコピーできるセキュリティー・ポリシーを生成します。

  6. コードの作成に使用したターゲット・エージェントに基づいて、ポリシーを次の場所に追加します。
    ターゲット・エージェント リポジトリーの場所と必要なファイル名 メモ/要件
    カーソル <root directory>/.cursorrules 代わりに、ファイルを .cursor/rules/ に置くこともできますが、ルート・ファイルは Phase 1 MVP を単純化するために最適です。
    Claude コード <root directory>/CLAUDE.md Anthropic のネイティブ・スタンディングオーダー形式。このファイルが既に存在する場合は、このファイルに手順を追加する必要があります。
    GitHub CoPilot <root directory>/copilot-instructions.md すべての Copilot チャット・セッションの開始時に自動的に解析されます。
    Windsurf (Cascade) <root directory>/.windsurfrules Cascade のメモリー層がラッチされるようにするには、単純なマークダウン・ヘッダーが必要です。
    Universal Fallback <root directory>/AGENTS.md 複数のオープンソース・エージェント・フレームワークでサポートされる、新たな相互互換性のあるエコシステム標準。

サンプル出力

# AI Coding Security Policy — FastAPI / Python 3.12

> Security policies for AI coding assistants in this repository.
> Save as `.appscan/policy.md` in the repo root.

## Anti-Hallucination Rules

- NEVER invent library names, package names, framework APIs, middleware, or configuration flags not present in this stack.
- NEVER suggest packages you cannot confirm are real and actively maintained for Python 3.12.
- If uncertain whether a function or package exists in Python 3.12 — say so explicitly.
- NEVER fabricate security controls or framework features.

## Security Baseline

- NEVER disable or bypass FastAPI, Starlette, or server security controls for convenience.
- NEVER hardcode credentials, API keys, JWT secrets, or connection strings in source code or version-controlled files.
- ALWAYS validate and sanitize all external input at the API boundary using explicit request models and strict typing.
- NEVER silently swallow security-related exceptions.
- REQUIRED: apply least privilege to service accounts, MongoDB users, and any backing services.
- REQUIRED: use Python 3.12 standard-library security-safe primitives where available; prefer `secrets` over `random` for security-sensitive values.

## NoSQL Injection Prevention

- NEVER pass user input as MongoDB query operators, filters, or document keys without strict validation.
- MUST validate all query inputs are scalar values unless a specific structured schema is explicitly required.
- REQUIRED: reject objects containing `$`-prefixed keys or unsafe operator injection from client input.
- REQUIRED: use ODM / typed access-layer methods exclusively for query construction.
- NEVER use `$where` with user input; use explicit field matching only.

## JWT Security

- NEVER accept tokens without verifying the cryptographic signature server-side.
- MUST allowlist signing algorithms such as `RS256` or `ES256`; NEVER permit `alg: "none"`.
- REQUIRED: validate `exp`, `iss`, `aud`, and `nbf` on every protected request.
- NEVER trust client-decoded JWT claims without server-side re-verification.
- NEVER store tokens in browser-accessible storage; prefer `HttpOnly`, `Secure` cookies when feasible.
- REQUIRED: centralize token validation in FastAPI dependencies or middleware and enforce authorization on every protected route.

## Sensitive Data / PII Handling

- TREAT all PII as high-sensitivity data and collect only fields required for the business purpose.
- NEVER log PII, authentication tokens, or raw request bodies containing personal data.
- REQUIRED: mask or redact PII in application logs, error messages, traces, and monitoring events.
- REQUIRED: encrypt PII in transit and at rest using approved platform controls.
- NEVER return unnecessary PII fields in API responses; use response models to minimize exposure.
- REQUIRED: enforce server-side authorization checks before any read, update, export, or deletion of PII.
- REQUIRED: define retention and deletion behavior for PII; NEVER keep personal data indefinitely by default.

## Supply Chain Control

- MUST pin or constrain security-critical dependency versions; avoid unbounded ranges.
- NEVER introduce dependencies with known unpatched CVEs without security review.
- REQUIRED: run vulnerability scanning in CI using tools appropriate for Python dependencies.