abhishekamralkar/argus

GitHub: abhishekamralkar/argus

基于RAG技术的本地化漏洞扫描器,支持Go、Python、Rust项目依赖的安全检测,完全由本地Ollama模型驱动。

Stars: 8 | Forks: 0

# argus 一个基于 RAG(检索增强生成)的漏洞扫描器,支持 **Go**、**Python** 和 **Rust** 项目 — 完全由本地 [Ollama](https://ollama.com) 模型驱动。无需 API 密钥。无需云端。您的代码留在本地机器上。 [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/938e8719e7165851.svg)](https://github.com/abhishekamralkar/argus/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) [![Go Version](https://img.shields.io/badge/go-1.26+-00ADD8.svg)](https://golang.org) [![Release](https://img.shields.io/github/v/release/abhishekamralkar/argus)](https://github.com/abhishekamralkar/argus/releases) ## 快速开始 ``` # 安装 go install github.com/abhishekamralkar/argus/cmd/argus@latest # 启动 Ollama 并拉取模型 ollama pull nomic-embed-text ollama pull gpt-oss:20b # 导入漏洞数据库(一次性操作,约 5-10 分钟) argus ingest --ecosystems go # 检查数据库状态 argus status # 扫描项目 argus scan /path/to/your/project # 检查版本 argus version ``` 结果以颜色编码的严重级别流式输出到终端;当发现结果达到或超过您设置的 `--fail-on` 阈值(默认:HIGH)时,退出码为 `1`。 ## 工作原理 ``` ┌─────────────────────────────────────────────────────────────────┐ │ INGEST (one-time) │ │ │ │ OSV Feed ──┐ │ │ GoVulnDB ──┼──► Parse ──► Chunk ──► Embed (nomic-embed-text) │ │ RustSec ──┤ 512 chars (Ollama, local) │ │ PyPA ──┘ ──► DuckDB (local) │ └─────────────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────────────┐ │ SCAN (per project) │ │ │ │ go.mod / requirements.txt / Cargo.toml │ │ │ │ │ ▼ │ │ Parse deps ──► Embed query ──► Cosine search (DuckDB) │ │ │ │ │ ▼ │ │ Ignore list · Alias dedup · Version filter │ │ Min-severity gate · Parallel workers │ │ │ │ │ ▼ │ │ LLM prompt (gpt-oss:20b) ──► Report │ └─────────────────────────────────────────────────────────────────┘ ``` ## 功能特性 | 类别 | 功能 | |---|---| | **隐私** | 完全本地化 — Ollama 模型 + 磁盘上的 DuckDB,摄取后零外部 API 调用 | | **语言支持** | Go (`go.mod`)、Python (`requirements.txt`)、Rust (`Cargo.toml`) | | **数据源** | OSV、Go Vulnerability Database、RustSec、PyPA | | **检索** | 文档分块(512 字符重叠)、语义余弦搜索 | | **准确性** | 版本感知的 CVE 过滤 — 已修复的公告会被静默跳过 | | **准确性** | 别名感知的去重 — `GO-2024-x` 和 `CVE-2024-x` 不会重复报告 | | **噪音控制** | `--min-severity` 隐藏 LOW/MEDIUM 发现;`.argusignore` 接受/抑制已知的误报 | | **输出** | 颜色编码的终端输出、`--output json`、`--output sarif`(GitHub Security 标签) | | **性能** | 并行扫描工作器、并行嵌入工作器、Ollama 错误时的指数退避重试 | | **CI** | `--fail-on` 阈值标志,发现问题时非零退出,SARIF 上传支持 | | **配置** | `.argus.yaml` 项目配置文件 — 无需在每个 CI 命令中重复标志 | ## 前置条件 | 要求 | 版本 | 备注 | |---|---|---| | Go | 1.26+ | `go install` 构建二进制文件 | | [Ollama](https://ollama.com) | 最新版 | 必须在本地运行 | | DuckDB CLI | 可选 | 用于手动数据库检查 | ### 拉取所需的 Ollama 模型 ``` ollama pull nomic-embed-text # embedding model (768-dim) ollama pull gpt-oss:20b # LLM for vulnerability analysis ``` ## 安装 ### 从源码构建 ``` git clone https://github.com/abhishekamralkar/argus.git cd argus make build # embeds git version in binary ./argus version ``` ### go install ``` go install github.com/abhishekamralkar/argus/cmd/argus@latest ``` ### 下载发布版二进制文件 Linux、macOS 和 Windows(amd64 + arm64)的预构建二进制文件位于 [Releases](https://github.com/abhishekamralkar/argus/releases) 页面。包含 SHA-256 校验和和 cosign 签名。 ### Docker ``` docker run --rm \ -v "$PWD:/project" \ -v argus-data:/data \ -e OLLAMA_HOST=http://host.docker.internal:11434 \ ghcr.io/abhishekamralkar/argus \ scan /project ``` ## 命令 ### `ingest` — 填充漏洞数据库 将所有漏洞数据库下载并嵌入到本地 DuckDB 文件中。运行一次,然后定期运行以获取新的公告。重新运行是安全的 — 过期块会被替换,而不是累积。 ``` # 所有生态系统(默认) argus ingest # 特定生态系统 argus ingest --ecosystems go,python # 自定义数据库路径 argus ingest --db /var/lib/argus/vulns.db # 调整分块大小(默认:512 字符,64 重叠) argus ingest --chunk-size 256 --chunk-overlap 32 # 禁用分块(每个公告单独嵌入) argus ingest --no-chunk # 使用更多工作线程加快导入速度 argus ingest --workers 16 ``` **下载内容:** | 来源 | 生态系统 | |---|---| | OSV | Go、Python、Rust | | Go Vulnerability Database | Go | | RustSec advisory database | Rust | | PyPA advisory database | Python | ### `status` — 数据库健康检查 ``` argus status ``` ``` Vulnerability Database — ./vulns.db ECOSYSTEM | VULNERABILITIES | CHUNKS | LAST INGEST go | 6556 | 48203 | 2026-05-03T08:12:00Z python | 19045 | 134821 | 2026-05-03T08:31:00Z rust | 2267 | 15901 | 2026-05-03T08:36:00Z ``` ### `scan` — 分析项目依赖 ``` argus scan /path/to/your/project ``` **文本输出(默认,带颜色编码):** ``` ╔══════════════════════════════════════════════════════╗ ║ argus scan: /path/to/your/project ║ ║ 42 dependencies found ║ ╚══════════════════════════════════════════════════════╝ ┌─ [1/42] golang.org/x/crypto @ 0.0.0-20190308221718 (go) ID | PACKAGE | SEVERITY | FIXED IN | SCORE GO-2021-0227 | golang.org/x/crypto | HIGH | 0.17.0 | 0.923 Analyzing with gpt-oss:20b (streaming)... ──────────────────────────────────────────────────────────── 1. Vulnerable: YES 2. Severity: HIGH 3. Advisory: GO-2021-0227 (CVE-2021-43565) 4. Fix: upgrade to golang.org/x/crypto v0.17.0 or later 5. The SSH server implementation accepts an empty plaintext password even when password auth is disabled. ``` **JSON 输出:** ``` argus scan . --output json > results.json ``` ``` { "scanned_at": "2026-05-03T10:00:00Z", "results": [ { "package": "golang.org/x/crypto", "version": "0.0.0-20190308221718", "ecosystem": "go", "verdict": "HIGH", "severity": "HIGH", "cve_count": 1, "findings": [ { "id": "GO-2021-0227", "severity": "HIGH", "fixed_in": "0.17.0", "score": 0.923 } ] } ] } ``` **SARIF 输出**(GitHub Security 标签): ``` argus scan . --output sarif > argus.sarif ``` **所有扫描标志:** | 标志 | 默认值 | 描述 | |---|---|---| | `--output` | `text` | 输出格式:`text`、`json`、`sarif` | | `--min-severity` | (全部) | 报告的最低严重级别:`LOW`、`MEDIUM`、`HIGH`、`CRITICAL` | | `--fail-on` | `HIGH` | 触发退出码 1 的最低严重级别 | | `--workers` | `4` | 并行依赖分析工作器 | | `--enhance-query` | 关闭 | LLM 在嵌入前扩展搜索查询 | | `--llm-model` | `gpt-oss:20b` | Ollama 生成模型 | | `--embed-model` | `nomic-embed-text` | Ollama 嵌入模型 | | `--db` | `./vulns.db` | DuckDB 数据库路径 | ### `search` — 临时语义搜索 ``` argus search "sql injection python" argus search "memory corruption" --ecosystem rust argus search "path traversal" --ecosystem go --limit 5 ``` ### `completion` — shell 补全 ``` # Bash argus completion bash > /etc/bash_completion.d/argus # Zsh argus completion zsh > "${fpath[1]}/_argus" # Fish argus completion fish > ~/.config/fish/completions/argus.fish # PowerShell argus completion powershell | Out-String | Invoke-Expression ``` ## 配置文件 将 `.argus.yaml` 放在项目根目录,以避免在每次运行时重复标志。CLI 标志始终优先。 ``` # .argus.yaml min_severity: MEDIUM # skip LOW findings workers: 8 # more parallel analysis workers llm_model: gpt-oss:20b embed_model: nomic-embed-text ``` 请参阅 [`.argus.yaml.example`](.argus.yaml.example) 了解所有可用选项。 ## 忽略列表 在项目根目录创建 `.argusignore` 以抑制已知的误报或已接受的风险: ``` # .argusignore # 隐藏特定安全公告 GHSA-xxxx-yyyy-zzzz CVE-2024-1234 # 隐藏软件包的所有发现 requests golang.org/x/text ``` 以 `#` 开头的行是注释。ID 不区分大小写匹配,也会与公告别名匹配(例如,抑制 `GO-` ID 也会抑制其 `CVE-` 别名)。 ## CI/CD 集成 ### 基础 GitHub Actions ``` - name: Install argus run: go install github.com/abhishekamralkar/argus/cmd/argus@latest - name: Cache vulnerability database uses: actions/cache@v4 with: path: vulns.db key: argus-vulns-${{ runner.os }}-${{ steps.date.outputs.date }} restore-keys: argus-vulns-${{ runner.os }}- - name: Ingest vulnerability databases run: argus ingest --ecosystems go - name: Scan dependencies run: argus scan . --min-severity MEDIUM --fail-on HIGH ``` ### 带 SARIF 上传(GitHub Security 标签) ``` - name: Scan and emit SARIF run: argus scan . --output sarif > argus.sarif - name: Upload to GitHub Security tab uses: github/codeql-action/upload-sarif@v3 with: sarif_file: argus.sarif if: always() ``` ## 环境变量 | 变量 | 默认值 | 描述 | |---|---|---| | `OLLAMA_HOST` | `http://localhost:11434` | Ollama 服务器地址 | | `NO_COLOR` | (未设置) | 设置为任意值以禁用颜色输出 | ## 检查数据库 ``` argus status # quick summary duckdb vulns.db # full SQL access -- counts per ecosystem SELECT ecosystem, COUNT(*) FROM vulnerabilities GROUP BY ecosystem; -- chunk coverage SELECT v.ecosystem, COUNT(c.chunk_id) AS chunks FROM vulnerability_chunks c JOIN vulnerabilities v ON c.vuln_id = v.id GROUP BY v.ecosystem; -- last ingest times SELECT source, last_run_at FROM ingest_log ORDER BY last_run_at DESC; -- unpatched CRITICAL vulns SELECT id, package, ecosystem FROM vulnerabilities WHERE severity = 'CRITICAL' AND (fixed_in IS NULL OR fixed_in = ''); ``` ## 项目结构 ``` cmd/argus/main.go CLI entry point (cobra) internal/ color/color.go Color-coded severity/verdict output config/config.go .argus.yaml loader embed/ollama.go Ollama embedding client (nomic-embed-text) ignore/ignore.go .argusignore loader ingest/ osv.go OSV vulnerability feed (Go, PyPI, crates.io) govuln.go Go Vulnerability Database rustsec.go RustSec advisory database pypa.go PyPA advisory database chunk.go Document chunking (paragraph → sentence → char split) llm/ollama.go Ollama generation client (gpt-oss:20b, streaming + retry) output/output.go JSON and SARIF 2.1.0 report writers parser/ gomod.go go.mod parser requirements.go requirements.txt parser cargotoml.go Cargo.toml parser rag/query.go RAG pipeline — embed, retrieve, filter, prompt, generate store/ duckdb.go DuckDB vector store — schema, upsert, search, status types.go Shared Vulnerability type version/compare.go Semver comparison for version-aware CVE filtering ``` ## 运行测试 ``` # 所有测试 go test ./... # 带竞态检测器 go test -race ./... # 基准测试 go test -bench=. -benchmem ./internal/store/... ``` ## 贡献 欢迎贡献!请参阅 [CONTRIBUTING.md](CONTRIBUTING.md) 了解指南。 未来贡献的想法: - 支持 `poetry.lock`、`Pipfile.lock`、`package-lock.json`、`pom.xml` - 额外的生态系统(npm、Maven、NuGet) - 用于交互式浏览的 TUI / web 前端 - 通过 cron / systemd timer 计划的自动重新摄取 - SBOM 生成( CycloneDX、SPDX) ## 许可证 Apache 2.0 — 请参阅 [LICENSE](LICENSE)。
标签:AI风险缓解, AMSI绕过, CVE, DevSecOps, DuckDB, EVTX分析, Go安全, IPv6支持, LLM评估, Ollama, RAG, Rust安全, SBOM, 上游代理, 云安全监控, 代码安全, 代码生成, 可视化界面, 威胁检测, 数字签名, 日志审计, 本地大模型, 检索增强生成, 渗透测试工具, 漏洞枚举, 硬件无关, 网络安全, 软件供应链安全, 远程方法调用, 逆向工具, 隐私保护, 静态分析