Communitygithub.com

安全掃描 (security-scan)

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

安全掃描 (security-scan) 是什麼?

這個技能會利用 AgentShield 對 Claude Code 專案的 `.claude/` 設定目錄進行全面安全掃描。它能找出 CLAUDE.md 中的硬編碼機密、自動執行指令與提示注入模式;檢查 settings.json 中過於寬鬆的允許清單、遺漏的拒絕清單與危險的繞過旗標;評估 MCP 伺服器設定是否存在供應鏈風險及硬編碼環境變數;並檢測鉤子指令是否有命令注入或資料外洩的風險。該技能支援多種輸出格式(終端機、JSON、Markdown、HTML),可整合到 CI/CD 管線中,並提供自動修復功能,同時包含一個三階段對抗式深度分析管線(紅隊攻擊、藍隊防禦、最終審計)。支援 Claude Code 的所有主要平台,是專案安全稽核與定期安全衛生檢查的必備工具。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/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/透過插入(interpolation)進行的命令注入、資料外洩、靜默錯誤抑制
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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

相關技能