peaktwilight/foxguard

GitHub: peaktwilight/foxguard

一款基于 Rust 的超快速静态安全扫描器,支持 10 种语言、118 条内置规则,兼容 Semgrep 规则,适合开发阶段实时检测常见漏洞和敏感信息泄露。

Stars: 2 | Forks: 0

foxguard logo

foxguard

速度快如 Linter 的安全扫描器。
118 条内置规则 · 10 种语言 · 单个 Rust 二进制文件 · 亚秒级扫描

foxguard.dev · npm · crates.io

CI foxguard: clean npm

foxguard demo

大多数安全扫描器需要 10-30 秒。foxguard 不到一秒即可完成。速度快到可以在每次保存时运行,而不仅仅是在 CI 中。 ``` npx foxguard . ``` ``` src/auth/login.js 14:5 CRITICAL js/no-sql-injection (CWE-89) SQL query built with template literal interpolation src/utils/config.py 7:1 HIGH py/no-hardcoded-secret (CWE-798) Hardcoded secret in 'api_key' WARNING 2 issues found: 1 critical, 1 high, 0 medium, 0 low ``` ## 为什么选择 foxguard - **亚秒级扫描** — Rust + tree-sitter + rayon。无 JVM,无 Python 运行时,无网络调用。 - **118 条内置规则** — SQL 注入、XSS、SSRF、命令注入、硬编码 Secrets、弱加密、反序列化以及特定框架检查。 - **10 种语言** — JavaScript、TypeScript、Python、Go、Ruby、Java、PHP、Rust、C#、Swift。 - **Secrets 扫描** — AWS 密钥、GitHub/GitLab/Slack/Stripe token、私钥。输出已脱敏。 - **兼容 Semgrep** — 使用 `--rules` 加载现有的 YAML 规则。无供应商锁定。 - **Pre-commit 就绪** — `foxguard init` 安装 hook。配合 `--changed` 仅扫描更改的文件。 - **CI 友好** — Terminal、JSON、SARIF 输出。GitHub Code Scanning 集成。 ## 安装 ``` npx foxguard . # no install needed cargo install foxguard # or via Rust ``` ## 内置覆盖范围 | 语言 | 规则数 | 框架 | |----------|-------|------------| | JavaScript/TypeScript | 24 | Express, JWT, cookies, XSS | | Python | 26 | Flask, Django, CSRF, session | | Go | 8 | Gin, net/http, TLS | | Ruby | 10 | Rails, mass assignment, CSRF | | Java | 10 | Spring, XXE, deserialization | | PHP | 10 | Laravel, file inclusion, unserialize | | Rust | 10 | unsafe, transmute, TLS | | C# | 10 | .NET, LDAP, XXE, CORS | | Swift | 10 | iOS keychain, transport, WebView | ## 使用方法 ``` foxguard . # scan everything foxguard --changed . # scan only modified files foxguard --severity high . # filter by severity foxguard secrets . # scan for leaked credentials foxguard secrets --changed . # secrets on changed files only foxguard --format sarif . # SARIF for GitHub Code Scanning foxguard --rules ./my-rules . # add Semgrep-compatible YAML rules foxguard init # install pre-commit hook ``` ## CI 集成 ### GitHub Actions ``` name: Security on: [push, pull_request] jobs: foxguard: runs-on: ubuntu-latest permissions: security-events: write steps: - uses: actions/checkout@v4 - uses: peaktwilight/foxguard/action@v0.2.1 with: path: . severity: medium fail-on-findings: "true" upload-sarif: "true" ``` 结果显示在 **Security → Code Scanning** 中。 ### 任意 CI ``` npx foxguard@latest . # scan npx foxguard@latest --format sarif . > out.sarif # SARIF output npx foxguard@latest secrets . # secrets scan ``` ### 徽章 ``` [![foxguard](https://img.shields.io/badge/foxguard-clean-2dd4bf?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCIgZmlsbD0ibm9uZSI+PHBhdGggZD0iTTggOEwyMCAyOEwzMiAyMEw0NCAyOEw1NiA4TDUyIDMyTDQ0IDQ0TDM2IDUySDI4TDIwIDQ0TDEyIDMyTDggOFoiIGZpbGw9IiNGNTlFMEIiIGZpbGwtb3BhY2l0eT0iMC4zIiBzdHJva2U9IiNGNTlFMEIiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxjaXJjbGUgY3g9IjI0IiBjeT0iMzIiIHI9IjIuNSIgZmlsbD0iI0Y1OUUwQiIvPjxjaXJjbGUgY3g9IjQwIiBjeT0iMzIiIHI9IjIuNSIgZmlsbD0iI0Y1OUUwQiIvPjwvc3ZnPg==)](https://github.com/peaktwilight/foxguard) ``` ## 配置 foxguard 从扫描路径向上自动发现 `.foxguard.yml`。 ``` scan: baseline: .foxguard/baseline.json rules: ./semgrep-rules secrets: baseline: .foxguard/secrets-baseline.json exclude_paths: - fixtures - testdata ignore_rules: - secret/github-token ``` ## Semgrep 兼容性 使用 `--rules` 加载现有的 Semgrep/OpenGrep YAML 规则。支持 `pattern`、`pattern-regex`、`pattern-either`、`pattern-not`、`pattern-inside`、`pattern-not-inside`、`metavariable-regex` 和 `paths.include/exclude`。参见 [`COMPATIBILITY.md`](./COMPATIBILITY.md)。 ## 性能 foxguard 内置规则与 Semgrep `auto` 在真实仓库上的对比: | Repo | foxguard | Semgrep | 提速 | |------|----------|---------|---------| | express (141 files) | 0.284s | 17.4s | **61x** | | flask (83 files) | 0.084s | 7.3s | **87x** | | gin (99 files) | 0.516s | 8.0s | **16x** | 在本地运行 `./benchmarks/run.sh` 以复现。 *由 [Peak Twilight](https://doruk.ch) 构建 — 同时也在构建 [pwnkit](https://pwnkit.com)、[vibecheck](https://vibechecked.doruk.ch)、[unfuck](https://unfcked.doruk.ch)、[whatdiditdo](https://whatdiditdo.doruk.ch)* ## 许可证 MIT
标签:CISA项目, DOE合作, DvSec, GraphQL安全矩阵, Linter, npm包, pptx, Rust, SAST, SQL注入检测, tree-sitter, 二进制文件, 可视化界面, 多语言支持, 安全专业人员, 安全扫描器, 安全测试框架, 开发安全, 性能优化, 暗色界面, 检测绕过, 盲注攻击, 硬编码密码检测, 网络流量审计, 通知系统, 错误基检测, 静态代码分析