Communitygithub.com

安全性掃描

使用 AgentShield 掃描您的 Claude Code 設定(.claude/ 目錄)中的安全漏洞、配置錯誤和注入風險。適用於審計 CLAUDE.md、settings.json、MCP 伺服器、鉤子和代理定義。

安全性掃描 是什麼?

「安全性掃描」技能是一個專門針對 Claude Code 專案的安全審計工具,基於 AgentShield 框架。它能夠全面檢查 .claude/ 目錄下的設定檔,包括 CLAUDE.md(檢查硬編碼密碼、自動執行指令、提示注入模式)、settings.json(檢查過度寬鬆的白名單、缺少黑名單、危險的繞過標誌)、mcp.json(檢查風險 MCP 伺服器、硬編碼環境變量、npx 供應鏈風險)、hooks/(檢查命令注入、資料外洩、靜默錯誤抑制)以及 agents/*.md(檢查工具存取限制、提示注入表面)。此技能可透過 npx 直接執行,無需先安裝,也支援全局安裝。輸出格式包括終端機彩色報告、JSON(適用於 CI/CD 整合)、Markdown(適用於文件)和自包含的深色主題 HTML 報告。此外,它還提供自動修復功能、Opus 4.6 深度分析(紅隊/藍隊/審計員三管道),以及生成安全設定的初始化指令。支援 GitHub Action 整合,可設定最低嚴重性級別和出錯時失敗構建。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/security-scan

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

安全性掃描技能

使用 AgentShield 審計您的 Claude Code 設定是否存在安全問題。

何時啟用

  • 設定新的 Claude Code 專案時
  • 修改 .claude/settings.json、CLAUDE.md 或 MCP 設定後
  • 提交設定變更之前
  • 加入帶有現有 Claude Code 設定的新儲存庫時
  • 定期安全衛生檢查

掃描項目

檔案檢查內容
CLAUDE.md硬編碼機密、自動執行指令、提示注入模式
settings.json過度寬鬆的白名單、缺少黑名單、危險的繞過標誌
mcp.json高風險 MCP 伺服器、硬編碼環境變量、npx 供應鏈風險
hooks/透過插值命令注入、資料外洩、靜默錯誤抑制
agents/*.md無限制的工具存取、提示注入表面、缺少模型規格

先決條件

必須安裝 AgentShield。檢查並在需要時安裝:

# 檢查是否已安裝
npx ecc-agentshield --version

# 全域安裝(建議)
npm install -g ecc-agentshield

# 或直接透過 npx 執行(無需安裝)
npx ecc-agentshield scan .

使用方法

基本掃描

針對當前專案的 .claude/ 目錄進行掃描:

# 掃描當前專案
npx ecc-agentshield scan

# 掃描指定路徑
npx ecc-agentshield scan --path /path/to/.claude

# 使用最低嚴重性篩選
npx ecc-agentshield scan --min-severity medium

輸出格式

# 終端機輸出(預設)— 彩色報告及評級
npx ecc-agentshield scan

# JSON — 適用於 CI/CD 整合
npx ecc-agentshield scan --format json

# Markdown — 適用於文件
npx ecc-agentshield scan --format markdown

# HTML — 自包含的深色主題報告
npx ecc-agentshield scan --format html > security-report.html

自動修復

自動套用安全修復(僅修復標記為可自動修復的項目):

npx ecc-agentshield scan --fix

這將:

  • 將硬編碼機密替換為環境變量引用
  • 將萬用字元權限收緊為限定作用域的替代方案
  • 永不修改僅供手動建議的項目

Opus 4.6 深度分析

執行對抗性三管道進行更深入分析:

# 需要 ANTHROPIC_API_KEY
export ANTHROPIC_API_KEY=your-key
npx ecc-agentshield scan --opus --stream

這將執行:

  1. 攻擊者(紅隊) — 尋找攻擊向量
  2. 防禦者(藍隊) — 建議強化措施
  3. 審計員(最終裁決) — 綜合雙方觀點

初始化安全設定

從頭建立全新的安全 .claude/ 設定:

npx ecc-agentshield init

建立:

  • settings.json 附帶限定作用域的權限和黑名單
  • CLAUDE.md 附帶安全最佳實踐
  • mcp.json 佔位符

GitHub Action

新增至您的 CI 管道:

- uses: affaan-m/agentshield@v1
  with:
    path: '.'
    min-severity: 'medium'
    fail-on-findings: true

嚴重性等級

等級分數含義
A90-100安全設定
B75-89輕微問題
C60-74需要注意
D40-59重大風險
F0-39嚴重漏洞

解讀結果

嚴重發現(立即修復)

  • 設定檔中的硬編碼 API 金鑰或令牌
  • 白名單中的 Bash(*)(無限制的 shell 存取)
  • 透過 ${file} 插值進行命令注入的鉤子
  • 執行 shell 的 MCP 伺服器

高風險發現(上線前修復)

  • CLAUDE.md 中的自動執行指令(提示注入向量)
  • 權限中缺少黑名單
  • 具有不必要 Bash 存取權限的代理

中等發現(建議修復)

  • 鉤子中的靜默錯誤抑制(2>/dev/null、|| true)
  • 缺少 PreToolUse 安全鉤子
  • MCP 伺服器設定中的 npx -y 自動安裝

資訊發現(僅需了解)

  • MCP 伺服器缺少描述
  • 禁止性指令正確標記為良好實踐

連結

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相關技能