Defend-AI-Tech-Inc/agent-discover-scanner

GitHub: Defend-AI-Tech-Inc/agent-discover-scanner

一款企业级AI Agent发现与盘点工具,通过代码分析、网络监控和K8s运行时观测多层联动,识别并分类组织内的自主AI系统及其风险等级。

Stars: 6 | Forks: 1

# AgentDiscover 扫描器
**企业级开源 AI Agent 发现工具** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/) [![PyPI](https://img.shields.io/pypi/v/agent-discover-scanner.svg)](https://pypi.org/project/agent-discover-scanner/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md) *属于 [DefendAI](https://defendai.ai) 平台,用于自主 AI 治理*
大多数企业认为 AI 风险是指员工将数据粘贴到 ChatGPT 中。那是过去的问题。 真正的风险是**拥有 API 密钥、数据库访问权限和工具权限的 AI Agent 独立行动** —— 没有人工干预,没有注册表,没有治理。 AgentDiscover Scanner 是第一步:**发现所有正在运行的内容。** ## 它能发现什么 | 分类 | 含义 | 风险 | |---|---|---| | ✅ **CONFIRMED** | 在代码中检测到 Agent 且在运行时观察到正在运行 | 高 — 正在执行 | | 👻 **GHOST** | 在运行时观察到 Agent,但没有对应的源代码 | **严重 — 不受管控** | | ⚠️ **UNKNOWN** | 在代码中发现 Agent,但在运行时尚未观察到 | 中 — 未验证 | | ☠️ **ZOMBIE** | 代码中有 Agent,曾经处于活动状态,不再观察到 | 低 — 可能已废弃 | **GHOST Agent 是最危险的发现。** 一个 AI 系统正在进行真实的 API 调用 —— 消耗 token,可能正在访问数据 —— 但您的工程团队没有相关记录。没有代码,没有部署,没有负责人。 ## 快速开始 ``` # 安装 pip install agent-discover-scanner # 扫描 codebase agent-discover-scanner scan-all /path/to/your/code ``` 对于 Kubernetes 环境(完整部署): ``` curl -fsSL https://raw.githubusercontent.com/Defend-AI-Tech-Inc/agent-discover-scanner/main/install.sh | sudo bash agent-discover-scanner scan-all /path/to/code --daemon --output /var/log/defendai ``` ## 工作原理 AgentDiscover Scanner 结合了四种检测方法,并将它们关联到一个统一的 Agent 清单中。 **源代码分析** Python 和 JavaScript/TypeScript 代码库的静态分析。检测 LangChain、LangGraph、CrewAI、AutoGen、直接的 OpenAI/Anthropic/Gemini API 使用,以及任何针对 LLM 提供商端点的 HTTP 客户端。处理导入别名和间接使用模式。 **网络监控** 实时观察与 AI 提供商的出站连接 —— OpenAI、Anthropic、Google Gemini、Mistral、Cohere、Azure OpenAI、AWS Bedrock 以及向量存储(Pinecone、Weaviate、Qdrant)。无需数据包捕获;被动工作。 **Kubernetes 运行时监控** 集群内 Pod 行为的内核级可见性。识别哪些工作负载正在主动进行 AI 调用 —— 包括没有对应源代码的工作负载(GHOST Agent)。适用于任何 CNI(Flannel、Calico、Weave、AWS VPC CNI、GKE CNI 等)。 **端点发现** 扫描开发人员机器、CI/CD Runner 和工作站以查找 AI 工具使用情况 —— 已安装的 AI 包、桌面 AI 应用程序(ChatGPT Desktop、Claude Desktop、Cursor、GitHub Copilot)、活动的 AI 连接以及基于浏览器的 AI 使用。 ## 示例输出 ``` 🔍 Scanning for autonomous AI agents... 📂 Analyzing source code at ./my-repo 🌐 Monitoring live network connections... ☸️ Monitoring Kubernetes workloads... 🔗 Correlating findings... 🤖 Autonomous Agent Inventory ┌────────────────┬───────┬────────────────────────────────────────────────────┐ │ Classification │ Count │ Description │ ├────────────────┼───────┼────────────────────────────────────────────────────┤ │ CONFIRMED │ 2 │ Active — detected in code and observed at runtime │ │ UNKNOWN │ 3 │ Code found — not yet observed at runtime │ │ ZOMBIE │ 0 │ Inactive — code exists but no recent activity │ │ GHOST │ 1 │ ⚠ Critical — runtime activity with no source code │ └────────────────┴───────┴────────────────────────────────────────────────────┘ ✅ Scan complete — results saved to ./results ``` **GHOST Agent 告警:** ``` 👻 GHOST AGENT DETECTED Workload: trading-bot (Deployment/default) Runtime: Observed making live API calls to OpenAI Code: No source code found in scanned repositories Action: Investigate — this agent has no registered owner ``` ## Daemon 模式 作为后台服务持续运行,每 30 秒更新一次 Agent 清单: ``` # 启动 daemon agent-discover-scanner scan-all /path/to/code \ --daemon \ --output /var/log/defendai # 安装为 systemd 服务 (Linux) sudo bash deployment/systemd/install-service.sh /path/to/code systemctl status defendai-scanner ``` 新 Agent 在被发现时会出现在 `agent_inventory.json` 中。设计用于与现有安全工具一起在生产环境中部署。 ## CI/CD 集成 ``` # .github/workflows/agent-scan.yml - name: Scan for AI Agents run: | pip install agent-discover-scanner agent-discover-scanner scan . --format sarif --output results.sarif - name: Upload to GitHub Security uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarif ``` ## 命令 ``` # 完全扫描(推荐)— code + network + Kubernetes + endpoints agent-discover-scanner scan-all /path/to/code [OPTIONS] --duration SECONDS Runtime observation window [default: 60] --output PATH Results directory [default: ./results] --daemon Run continuously, updating inventory every 30s --layer3-file PATH Path to Kubernetes runtime log # 仅 Code scan agent-discover-scanner scan /path/to/code # Dependency 扫描 agent-discover-scanner deps /path/to/code # 仅 Network monitor agent-discover-scanner monitor --duration 60 # 仅 Kubernetes runtime monitor agent-discover-scanner monitor-k8s --duration 60 # Endpoint 扫描(当前机器) agent-discover-scanner endpoint ``` ## 检测到的框架与提供商 **AI 框架:** LangChain, LangGraph, CrewAI, AutoGen **LLM 提供商:** OpenAI, Anthropic, Google Gemini, Mistral, Cohere, Azure OpenAI, AWS Bedrock **向量存储:** Pinecone, Weaviate, Qdrant, Chroma **直接使用:** 任何针对已知 LLM API 端点的 HTTP 客户端 ## 试用演示 在 10 分钟内运行带有模拟 AI Agent 的完整演示: ``` git clone https://github.com/Defend-AI-Tech-Inc/agent-discover-scanner cd agent-discover-scanner/demo ./setup.sh # deploys LangChain, CrewAI, and a shadow agent to local Kubernetes agent-discover-scanner scan-all ./sample-repo --duration 60 ``` 预期:2 个 CONFIRMED Agent,1 个 GHOST Agent(shadow-agent —— 在没有源代码的情况下运行)。 ## 系统要求 | 能力 | 要求 | |---|---| | 代码扫描 | Python 3.10+,无额外依赖 | | 网络监控 | Python 3.10+,root/sudo | | Kubernetes 运行时 | kubectl, Helm 3+, root/sudo | | 端点发现 | Python 3.10+,root/sudo | 完整的 Kubernetes 设置:`install.sh` 会自动处理 Helm、运行时监控设置和权限。 ## DefendAI 平台 AgentDiscover Scanner 是 DefendAI 平台的**发现层** —— 这是为自主 AI 构建治理控制平面的第一步。 | 组件 | 状态 | 描述 | |---|---|---| | **AgentDiscover Scanner** | ✅ 开源 | 发现并分类 AI Agent | | **defendai-agent** | 🧪 Beta | 用于 AI 流量治理的 MITM 代理 | | **Policy Engine** | 🚧 即将推出 | 定义并执行 Agent 行为规则 | | **DefendAI Platform** | 💼 企业版 | 自主 AI 的全生命周期治理 | [defendai.ai](https://defendai.ai) · [playground.defendai.ai](https://playground.defendai.ai) · [support@defendai.ai](mailto:support@defendai.ai) ## 许可证 MIT — 可免费使用、部署和修改。 *由 [DefendAI](https://defendai.ai) 构建 · 保护自主 AI 的未来*
标签:AI Agent检测, AI治理, API安全, DevSecOps, Docker镜像, JSON输出, Kubernetes运行时安全, Python安全工具, Shadow AI发现, Web截图, 上游代理, 企业安全, 子域名突变, 安全专业人员, 容器安全, 异常检测, 网络资产管理, 逆向工具, 错误基检测, 静态代码分析