Ai Code Scanner

io.github.GuardBee由 GitHub 帳號 GuardBee 發布v0.5.1更新於 Nov 3, 2026

Scans code for insecure LLM/AI integration: exposed keys, unsafe output, prompt injection

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

掃描程式碼片段、檔案與目錄,找出 LLM/AI 整合中的不安全模式,例如金鑰外洩、輸出處理不當與提示注入。

可以做什麼
  • 掃描文字字串或程式碼片段中的不安全 AI/LLM 整合模式
  • 掃描單一檔案,或遞迴掃描目錄,並自動略過 node_modules、.git、dist 與二進位檔
  • 依類別列出內建偵測規則,包含從規則目錄載入的自訂規則
  • 提供嚴重程度、風險說明與修正建議,並支援 SARIF 輸出以接入 CI
適用情境
適合在審查或稽核呼叫大型語言模型、建置代理的程式碼時使用,讓助理標出用戶端外洩金鑰、執行模型輸出、代理工具權限過大、提示詞含個人資料或系統提示未淨化等風險。
執行需求
以 stdio 方式在本機執行,通常透過 npx 啟動 npm 套件 @guardbee/mcp-ai-code-scanner,需要 Node.js 以及下載該套件的網路存取。未宣告驗證、環境變數或標頭。可選擇以 guardbee.yml 與規則目錄中的自訂規則 JSON 檔進行設定。
安裝前請注意
偵測結果是基於文字樣式的啟發式比對,並非完整 AST 分析,每筆結果仍需人工複核。遙測預設關閉;設定 GUARDBEE_TELEMETRY=1 後,會將伺服器、工具、成功與否、耗時以及檔案路徑等短參數值傳送給第三方遙測套件,較長的字串與 content、token、password 等欄位會以佔位符取代。掃描過程會讀取你的原始碼檔案。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Ai Code Scanner,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

@guardbee/mcp-ai-code-scanner

🇬🇧 English | 🇹🇷 Türkçe | 🇨🇳 中文 | 🇯🇵 日本語 | 🇰🇷 한국어 | 🇧🇷 Português | 🇪🇸 Español | 🇩🇪 Deutsch

[npm version] [npm downloads] [License: MIT]

An MCP (Model Context Protocol) server that scans your codebase for security patterns commonly found in LLM/AI integrations.

While secret-scanner looks for leaked secrets/API keys, this package looks for patterns: how much a model's output is trusted, how privileged the tools it can call are, what data is sent to a third-party LLM — risks that a static credential scan can't catch.

Telemetry is off by default. With GUARDBEE_TELEMETRY=1 it sends the server, tool, success, duration and short parameter values such as a file path; longer strings and fields like content, token or password are replaced with a placeholder. See @guardbee/mcp-telemetry.

Claude ──► ai-code-scanner ──► Your codebase              │              ├─ Client-exposure    (dangerouslyAllowBrowser: true)              ├─ Output handling    (eval(llmOutput), unvalidated JSON.parse)              ├─ Excessive agency   (an agent tool named execute_command)              ├─ Data privacy       (email/national ID interpolated directly into a prompt)              └─ Prompt injection   (raw request data mixed into a system prompt)

Features

  • 10 patterns, 5 categories — client-exposure, output-handling, excessive-agency, data-privacy, prompt-injection
  • Every finding includes why it's risky and what to do about it (recommendation) — not just "found it"
  • SARIF 2.1.0 output — CI/CD integration (GitHub Code Scanning, etc.)
  • Config file support via guardbee.yml
  • Custom rule packs — extend detection with org-specific patterns (KVKK/GDPR field names, internal tool names) via JSON files, no fork required
  • 36 unit tests — a positive and a negative (false-positive) scenario for every built-in pattern, plus custom-rule loading/validation

Quick Start

Claude Desktop / MCP Client

json
{  "mcpServers": {    "guardbee-ai-code-scanner": {      "command": "npx",      "args": ["-y", "@guardbee/mcp-ai-code-scanner"]    }  }}

CLI (CI/CD)

bash
npx @guardbee/mcp-ai-code-scanner scan ./src --fail-on=high --format=sarif > results.sarif

MCP Tools

ToolDescription
scan_textScans a given text/code snippet
scan_fileScans a single file
scan_directoryRecursively scans a directory (node_modules, .git, dist skipped automatically)
list_patternsLists all supported patterns by category

Detected Patterns

CategoryPatternSeverityWhat it means
client-exposureopenai_dangerously_allow_browsercriticalOpenAI key leaked to the browser
client-exposureclient_bundled_ai_api_keycriticalAn AI key enters the client bundle via NEXT_PUBLIC_/VITE_/REACT_APP_
output-handlingeval_llm_outputcriticalModel output executed as code via eval()/Function()
output-handlingexec_llm_outputcriticalModel output passed to a shell command (command injection)
output-handlingllm_output_dangerously_set_inner_htmlhighModel output rendered as raw HTML (XSS)
output-handlingllm_json_no_validationmediumModel output JSON.parse'd without schema validation
excessive-agencyexcessive_agency_tool_namehighA tool that grants an agent shell/code execution
excessive-agencyunbounded_agent_loopmediumAn agent loop with no iteration bound (cost/DoS)
data-privacypii_field_in_llm_prompthighData like email/national ID/card number goes directly into a prompt
prompt-injectionunsanitized_input_in_system_promptmediumRaw request/user data mixed into a system prompt

These are heuristic findings — a static text-pattern scan, not a full AST analysis. Designed for a low false-positive rate, but every finding should still be reviewed manually.


Configuration (guardbee.yml)

yaml
ai-code-scanner:  fail-on: high       # any | critical | high | medium | low | none  max-files: 5000  rules-dir: .guardbee/rules   # custom rule packs, see below  exclude:    - ".test.ts"    - "fixtures/"

Custom rules

Built-in patterns cover common AI/LLM integration mistakes, but field names and internal conventions (e.g. which prop names carry KVKK-regulated data) are project-specific. Drop one or more JSON files into .guardbee/rules/ (configurable via rules-dir) and they're merged with the built-ins at scan time — for both the CLI and the MCP server (list_patterns marks them (custom)).

A file holds a single rule object or an array of them:

json
{  "id": "kvkk_musteri_tc_no",  "name": "musteriTcNo interpolated into a prompt",  "category": "data-privacy",  "pattern": "musteriTcNo",  "flags": "gi",  "severity": "high",  "recommendation": "Mask the national ID before it enters the prompt."}

category is one of client-exposure | output-handling | excessive-agency | data-privacy | prompt-injection | cost-control; severity is one of critical | high | medium | low. pattern is a JS regex source string (flags defaults to "g"). A rule id that collides with a built-in or another custom rule is rejected — the scanner keeps running but reports the problem on stderr and skips that entry.


Development

bash
npm run buildnpm test             # 36 unit tests

License

MIT — GuardBee

Feedback

Questions, ideas, or a false positive? Start a thread in GitHub Discussions or open an issue. If GuardBee is useful to you, a ⭐ on the repository helps others find it.

來源:packages/ai-code-scanner/README.md,提交 bc5997d

工具

4

scan_text

Scan a text string or code snippet for insecure AI/LLM integration patterns (client-exposed keys, unsafe output handling, excessive agent tool permissions, PII sent to a model, prompt injection surface).

輸入參數labelcontent必填

scan_file

Scan a single file for insecure AI/LLM integration patterns

輸入參數path必填

scan_directory

Recursively scan a directory for insecure AI/LLM integration patterns. Automatically skips node_modules, .git, dist, and binary files.

輸入參數path必填excludeincludemaxFiles

list_patterns

List all AI/LLM security patterns that the scanner can detect, grouped by category (including any custom rules loaded from .guardbee/rules)

無需輸入參數。

版本歷史

3
  1. v0.5.1最新Oct 30, 2026
  2. v0.4.2Oct 22, 2026
  3. v0.3.3Oct 13, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分