camlebrun/StackRadar
GitHub: camlebrun/StackRadar
StackRadar 利用 Mistral LLM 自动分析 GitHub 仓库的每日发布说明和安全公告,为数据与平台工程师生成包含 CVE 检测和严重程度标记的结构化摘要看板。
Stars: 0 | Forks: 0
# StackRadar
StackRadar 会获取你跟踪的 GitHub 仓库的 release notes,使用 Mistral LLM 对其进行分析,标记 CVE,并渲染出一个 bento 风格的摘要 —— 每天早上 UTC 时间 06:00 自动刷新。

## 功能
- **增量获取**新的 release(基于游标,不会重复处理)
- **分析**每次 release:通过 Mistral 使用 `mistral-small-latest` 生成摘要、关键变更、严重程度、CVE ID 和标签
- **丰富** CVE ID,从 NIST NVD 获取对应的 CVSS 分数
- **存储**:将每次 release 的数据作为一个 JSON blob 存入 Cloudflare R2
- **提供**一个 `/digest` API,供托管在 Cloudflare Pages 上的静态 bento 前端调用
## 架构
```
Cloud Scheduler (06:00 UTC daily)
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Cloud Run Job — git-release (Python 3.12 · europe-west9) │
│ │
│ repos.json defines what to track: │
│ ├── GitHub releases ──────────────► GitHub REST API │
│ │ (incremental, cursor-based; │
│ │ 2-major backfill on first run) │
│ ├── dbt-fusion changelog ──────────────► GitHub raw content │
│ ├── GCP Docs ──────────────► cloud.google.com │
│ │ (BigQuery, Lakehouse release notes) │
│ └── security advisories ──────────────► GitHub Security API │
│ │
│ For each new release / advisory: │
│ ├── LLM analysis ─────────────────────► Mistral API │
│ │ mistral-small-latest │
│ │ 6 specialised prompts: │
│ │ standard · bigquery · lakehouse │
│ │ dbt-package · dbt-fusion · dbt-fusion-historical │
│ ├── CVE enrichment ────────────────────► NIST NVD API │
│ │ CVSS scores appended to cve_references[] │
│ └── Cloudflare R2 (boto3, S3-compatible) │
│ releases/{owner}/{repo}/{tag}.json │
│ meta/cursor/{owner}/{repo}.json │
│ meta/advisory-cursor/{owner}/{repo}.json │
│ meta/run_status.json │
│ advisories/{owner}/{repo}/advisories.json │
│ digest.json (pre-built sorted digest, served cold) │
│ │
│ Post-run (new releases only) ─────────► Cloud Function │
│ OIDC HTTP POST email-digest │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────┐
│ Cloud Function │
│ email-digest │
│ Python 3.12 │
│ europe-west9 │
│ │
│ GCP Secret Manager │
│ ├── GMAIL_ADDRESS │
│ ├── GMAIL_APP_PASSWD │
│ └── NOTIFY_EMAIL │
│ │
│ Gmail SMTP (port 465) │
│ → digest or fail HTML │
└────────────────────────┘
Cloudflare Pages (static, built with Vite)
├── / → main digest (bento cards, CVE table, filters)
├── /bigquery → BigQuery-specific release view
├── /lakehouse → Lakehouse-specific release view
├── /dbt-packages → dbt packages release view (sorted by date)
├── /dbt-fusion → dbt-fusion release view
└── /security → security advisories view
all tabs read digest.json directly from Cloudflare R2
Secrets & config
└── GCP Secret Manager → MISTRAL_API_KEY · GITHUB_TOKEN · TRIGGER_SECRET
R2_ACCESS_KEY_ID · R2_SECRET_ACCESS_KEY · R2_ACCOUNT_ID
EMAIL_FUNCTION_URL
(falls back to .env.local for local dev via src/secrets.py)
CI / CD
├── GitHub Actions ci.yml → ruff · black · pytest [on every PR]
├── GitHub Actions deploy.yml → deploy Cloud Function [on push to main]
└── Cloud Build → Docker build → Artifact Registry
→ deploy Cloud Run Job
```
## 跟踪的仓库
在 [`repos.json`](repos.json) 中配置:
```
[
"cli/cli",
"vitejs/vite",
"astral-sh/uv",
"dbt-labs/dbt-core"
]
```
添加仓库的方法:追加 `"owner/repo"` 并部署。下次运行时会自动回填最近 2 个主要版本的数据。
## 本地开发
```
# Python 设置
pip install -r requirements-dev.txt
# 复制并填写 secrets
cp .env.local.example .env.local
# 运行 tests
make test
# Type check
make typecheck
# 启动本地 function server
make dev
# → http://localhost:8080/digest
# → http://localhost:8080/health
# → curl -X POST -H "X-Trigger-Secret: " http://localhost:8080/trigger
```
## 环境变量 (`.env.local`)
| 变量 | 必需 | 描述 |
|---|---|---|
| `MISTRAL_API_KEY` | 是 | [Mistral](https://console.mistral.ai) API 密钥 |
| `GITHUB_TOKEN` | 否 | GitHub PAT — 将速率限制从 60 提升至 5,000 请求/小时 |
| `TRIGGER_SECRET` | 是 | 随机字符串 — 用于保护 `/trigger` endpoint |
| `R2_ACCESS_KEY_ID` | 是 | Cloudflare R2 API token ID |
| `R2_SECRET_ACCESS_KEY` | 是 | Cloudflare R2 API token 密钥 |
| `R2_ACCOUNT_ID` | 是 | Cloudflare 账户 ID |
在生产环境中,这些内容会存储在 **GCP Secret Manager** 中,绝不保存在环境变量文件中。
## API endpoint
| Endpoint | 认证 | 描述 |
|---|---|---|
| `GET /digest?limit=N` | 无 | 最近 N 个 release(默认 20,最大 100) |
| `GET /health` | 无 | 上次运行的时间戳及每个仓库的状态 |
| `POST /trigger` | `X-Trigger-Secret` header | 立即运行 pipeline |
## 前端
- **Digest 标签页** — release 卡片的 bento 网格布局:严重程度徽章、LLM 摘要、关键变更、CVE 标签
- **CVE 标签页** — 汇总所有 release 的 CVE 表格,按严重程度 + CVSS 分数排序,并附带 NVD 链接
- 实时搜索功能可同时过滤这两个标签页
- 支持深色模式,响应式布局(移动端 → 桌面端)
## 项目文档
| 文档 | 描述 |
|---|---|
| [`docs/sdd.md`](docs/sdd.md) | 本项目使用的规范驱动开发方法论 |
| [`docs/constitution.md`](docs/constitution.md) | 不可变架构原则 |
| [`docs/specification.md`](docs/specification.md) | 功能性与非功能性需求 |
| [`docs/plan.md`](docs/plan.md) | 技术蓝图与 API 契约 |
## 贡献指南
请参阅 [`CONTRIBUTING.md`](CONTRIBUTING.md)。
标签:Cloudflare, MITRE ATT&CK, Python, XSS, 无后门, 漏洞情报, 研发效能, 网络测绘, 请求拦截