manojmallick/supplyguard

GitHub: manojmallick/supplyguard

基于 Splunk 的智能体式软件供应链安全工具,通过 CI/CD 事件感知、CVE 与 typosquatting 检测、安全模型分诊以及构建拦截,实现从依赖变更发现到风险处置的自动化闭环。

Stars: 0 | Forks: 0

# SupplyGuard — Splunk 上的 Agentic 软件供应链安全

Splunk Track Python MCP Hosted Models Compliance Demo License

供应链攻击(XZ Utils、SolarWinds、Log4Shell)都从同一扇门进入:一个以前不存在的依赖项,或者一个被悄悄篡改的依赖项。大多数安全团队监控网络流量;但几乎没有人实时监控他们的**构建流水线**。 **SupplyGuard** 将 CI/CD 事件采集到 Splunk 中,然后运行一个 **agent** 来实现闭环:它感知新增/变更的依赖项,检测 CVE 和 typosquatting,通过 Splunk 托管的安全模型进行分诊,并**拦截构建**——同时在此过程中生成 NIS2 第 21 条的证据链。 ## 为什么这是 *agentic ops*,而不是一个 CI lint 步骤 ![SupplyGuard 架构 — CI/CD → HEC → Splunk;agent 通过 MCP 感知,使用托管模型进行分诊,拦截构建](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/e46ce28145172355.png) ``` CI/CD events ┌──────────────── SupplyGuard Agent ───────────────┐ (GitHub/GitLab/Jenkins) │ 1. SENSE manifest diff ← Splunk MCP Server │ │ HEC │ 2. DETECT CVE + typosquat (real edit dist) │ ▼ │ 3. INVESTIGATE Foundation-sec triage + impact │ index=cicd ───────────────► │ 4. DECIDE block / PR / report / flag │ │ SPL │ 5. ACT ► human-approval gate ◄ │ ▼ │ 6. LOG decision → index=cicd (NIS2 trail)│ Dashboards / Alerts └──────────────────────────────────────────────────┘ ``` | 能力 | 位置 | 奖项相关性 | |---|---|---| | **Splunk MCP Server** | `mcp_client.py` — agent 通过 `run_splunk_query`(带有 `initialize` 握手)读取 CI/CD | *Splunk MCP Server 最佳应用奖* | | **Splunk 托管模型** | `judge.py` — `foundation-sec-1.1-8b-instruct` 分类 typosquatting 并编写 NIS2 记录 | *Splunk 托管模型最佳应用奖* | | **HEC + SPL** | `collector.py`、`spl/` — 采集 + 分析(无需 `levenshtein`,无需 `join`) | 安全核心 | | **审批关卡** | `actions.py` — 除非使用 `--auto`,否则硬性拦截构建需要人工介入 | 负责任的自动化 | ## 运行(无需网络,约 2 秒) ``` cd supplyguard python demo.py # human-approval gate ON → block staged python demo.py --auto # autonomous → build blocked ``` 演示会感知到构建 `payment-service#1247`,它添加了 `reqursts@2.1.3`(与 `requests` 的编辑距离为 1)和 `log4j-core@2.14.0`(CVE-2021-44228,CVSS 10.0)。观看它感知 → 检测 → 分诊 → 决策 → 执行 → 记录。无需 Splunk 实例或 API 密钥(默认为 `SUPPLYGUARD_DEMO=1`)。 ### 针对实时的 Splunk 实例 ``` export SUPPLYGUARD_DEMO=0 export SPLUNK_HEC_URL=... SPLUNK_HEC_TOKEN=... # Splunk Cloud MCP endpoint(token audience 必须为 'mcp'): export SPLUNK_MCP_URL=https://.api.scs.splunk.com//mcp/v1/ export SPLUNK_MCP_TOKEN=... export SPLUNK_HOSTED_MODEL=foundation-sec-1.1-8b-instruct pip install -r requirements.txt python demo.py --auto ``` 密钥**仅**来自环境变量——绝不硬编码,且始终在日志中掩码处理(`Config.mask_token`)。 ## 与原始计划相比的变更 初稿*声称*使用了 AI,但实际上只提供了 SPL 和一个虚假的 `levenshtein()`。此版本修复了这个问题: - **真正的 Agentic** — 一个真实的 SENSE→…→ACT 控制循环(`agent.py`),而不是一次性脚本。 - **真正的 AI** — 由 Splunk 托管的安全模型对威胁进行分类并编写 NIS2 报告(`judge.py`),而不是硬编码的 `return 0.7`。 - **正确的 Splunk 交互层** — 通过 MCP Server 的 `run_splunk_query` 工具读取,并使用 streamable-HTTP 的 `initialize` 握手。 - **修复了 SPL 的 Bug** — `levenshtein()`(并非原生 SPL 函数)改在 Python 中计算;`join` 反模式被 `lookup`/`stats` 替换。 - **无硬编码密钥** — 仅限环境变量、掩码处理、气隙隔离演示。 ## 仓库结构 ``` supplyguard/ ├── supplyguard/ │ ├── config.py env-only secrets, risk thresholds, demo mode │ ├── collector.py CI/CD events → HEC (privacy-safe) │ ├── mcp_client.py Splunk MCP Server client (handshake) — agent reads Splunk │ ├── analyzer.py CVE lookup + real Levenshtein typosquat detection │ ├── judge.py Foundation-sec hosted model: triage + NIS2 narrative │ ├── actions.py block / PR / report / flag (+ approval gate) │ └── agent.py the agentic loop ← the core ├── demo.py runnable end-to-end demo (no network) └── spl/ SPL analytics + NIS2 posture queries ``` *© 2026 Manoj Mallick · MIT License*
标签:AI智能体, CI/CD安全, DevSecOps, Llama, 上游代理, 合规遵循, 后端开发, 文档安全, 软件供应链安全, 远程方法调用