用 Rust 编写的、像代码检查工具一样快速的安全扫描器。
A security scanner as fast as a linter – written in Rust

原始链接: https://github.com/peaktwilight/foxguard

## foxguard:快速、本地代码扫描 foxguard 是一款极速、单文件 Rust 二进制安全扫描器,专为频繁本地使用而设计,解决了传统安全工具速度慢的问题。它可以在**一秒钟内**扫描代码,使开发者能够在开发*过程中*(保存、提交或推送时)识别漏洞,而无需等待 CI 结果。 它内置了**100 多个规则**,涵盖 **10 种语言**(JavaScript、Python、Go、Ruby、Java、PHP、Rust、C#、Swift),覆盖 SQL 注入、硬编码密钥和 XSS 等常见问题。基准测试表明,与 Semgrep 相比,速度提升高达 **482 倍**。 foxguard 易于采用,为已经使用 Semgrep 规则的团队提供 **Semgrep 兼容的 YAML 桥接**。它以终端、JSON 或 SARIF 格式输出结果,并与 GitHub 代码扫描集成。 主要功能包括密钥扫描、修改文件扫描和仓库本地基线。它是更大的开源安全堆栈的一部分,与 pwnkit(渗透测试)和 opensoar(SOAR)并列。安装可以通过 `npm`、`crates.io`、`brew` 或 VS Code 扩展轻松完成。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 一个像代码检查工具一样快速的安全扫描器 – 用 Rust 编写 (github.com/peaktwilight) 13 分,由 peaktwilight 1 小时前发布 | 隐藏 | 过去 | 收藏 | 2 条评论 帮助 mplanchard 6 分钟前 | 下一个 [–] 看起来很有趣,会在$work的代码库上运行一下。README 中如果能提供更大代码库的基准测试会更好。基准测试表中的所有内容都比较小。我也会列出文件数量和行数,因为后者是代码量的更好衡量标准。作为参考,我最常使用的代码库有 1200 个 JS/TS 文件,685 个 Rust 文件,以及更多。JS 代码行数为 13k,TS 代码行数为 80k,Rust 代码行数为 155k。回复 mplanchard 1 分钟前 | 父评论 | 下一个 [–] 顺便说一句,即使在该代码库上,它仍然很快。10.7 毫秒。回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

foxguard logo

Sub-second local security scanning for real codebases.
100+ built-in rules · 10 languages · single Rust binary · Semgrep-compatible YAML bridge

foxguard.dev · npm · crates.io

A PwnKit Labs product.

CI foxguard: clean crates.io npm


foxguard vs semgrep side-by-side

Security scanners are slow. 10 seconds, 30 seconds, sometimes a minute. So developers don't run them locally — they get pushed to CI, findings pile up in PRs, and nobody looks at them.

foxguard fixes this by being fast enough that you never notice it's there. Same scan, 0.03 seconds instead of 10. You can run it on every save, every commit, every push. Security feedback becomes instant.

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 in 5 files (0.03s): 1 critical, 1 high, 0 medium, 0 low
  • Fast enough to leave on. foxguard is built for local runs, pre-commit hooks, and changed-file scans instead of “security later in CI”.
  • Useful before you tune anything. The default value is built-in framework-aware rules for common real-world mistakes across JavaScript, Python, Go, Ruby, Java, PHP, Rust, C#, and Swift.
  • Adoption-friendly. If you already have Semgrep/OpenGrep YAML, foxguard can load a focused compatible subset on top of built-ins so migration is incremental instead of all-or-nothing.
npx foxguard .                 # scan the repo
npx foxguard --changed .       # only modified files
npx foxguard secrets .         # leaked credentials and private keys
npx foxguard init              # install a local pre-commit hook

Rust + tree-sitter for AST parsing + rayon for parallelism. No JVM startup, no Python interpreter, no network calls, no rule download step. Just a native binary that reads your files and reports findings.

100+ built-in rules across 10 languages. SQL injection, XSS, SSRF, command injection, hardcoded secrets, weak crypto, unsafe deserialization, log injection, and framework-specific checks for Express, Django, Rails, Spring, Laravel, Gin, .NET, and iOS.

Also scans for leaked credentials (AWS keys, GitHub/GitLab/Slack/Stripe tokens, private keys) with redacted output. Loads Semgrep-compatible YAML rules with --rules if you have existing ones. Outputs terminal, JSON, or SARIF for GitHub Code Scanning.

foxguard dogfoods itself — it scans its own Rust source in CI on every push.

foxguard is not trying to be a full Semgrep or OpenGrep drop-in replacement.

The intended model is:

  • foxguard built-ins for fast local feedback
  • Semgrep/OpenGrep-compatible YAML subset as an adoption bridge
  • Semgrep/OpenGrep themselves when you need the broadest external rule ecosystem

That boundary is deliberate. It keeps local scans fast, rule support understandable, and compatibility claims testable.

npx foxguard .                         # no install needed
brew install peaktwilight/tap/foxguard # Homebrew (macOS/Linux)
cargo install foxguard                 # crates.io

Editor: Install the VS Code extension — scans on save, shows findings as underlines.

Real-world benchmarks on local codebases:

Repo Files foxguard Semgrep (cached) Speedup
youtube-reader (Next.js) 41 0.03s 4.6s 153x
doruk.ch (Astro) 28 0.04s 5.4s 134x
SwissPriceScraper (Python) 17 0.01s 4.8s 482x
express (framework) 141 0.28s 17.4s 61x
flask (framework) 83 0.08s 7.3s 87x

Semgrep times measured with cached rules (second run). foxguard has no cache — it's just fast.

Language Rules Frameworks
JavaScript/TypeScript 25 Express, JWT, cookies, XSS, log injection
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
  • Changed-file scans for tight local loops
  • Repo-local baselines so legacy findings stop blocking adoption
  • Secrets scanning alongside code scanning
  • JSON and SARIF output for CI and GitHub Code Scanning
  • Semgrep/OpenGrep YAML subset when teams already have rule investments

Load existing Semgrep/OpenGrep YAML rules with --rules. Supports pattern, pattern-regex, pattern-either, pattern-not, pattern-inside, pattern-not-inside, metavariable-regex, and paths.include/exclude. This supported subset is parity-tested in CI against the real semgrep CLI. See COMPATIBILITY.md.

foxguard does not currently aim to support multiple unrelated external rule formats. The compatibility target is the focused Semgrep/OpenGrep YAML subset above.

name: Security
on: [push, pull_request]
jobs:
  foxguard:
    runs-on: ubuntu-latest
    permissions:
      security-events: write
    steps:
      - uses: actions/checkout@v4
      - uses: PwnKit-Labs/foxguard/[email protected]
        with:
          path: .
          severity: medium
          fail-on-findings: "true"
          upload-sarif: "true"

Findings show up in Security → Code Scanning.

npx foxguard@latest .                             # scan
npx foxguard@latest --format sarif . > out.sarif   # SARIF output
npx foxguard@latest secrets .                      # secrets
[![foxguard](https://img.shields.io/badge/foxguard-clean-2dd4bf?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCIgZmlsbD0ibm9uZSI+PHBhdGggZD0iTTggOEwyMCAyOEwzMiAyMEw0NCAyOEw1NiA4TDUyIDMyTDQ0IDQ0TDM2IDUySDI4TDIwIDQ0TDEyIDMyTDggOFoiIGZpbGw9IiNGNTlFMEIiIGZpbGwtb3BhY2l0eT0iMC4zIiBzdHJva2U9IiNGNTlFMEIiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxjaXJjbGUgY3g9IjI0IiBjeT0iMzIiIHI9IjIuNSIgZmlsbD0iI0Y1OUUwQiIvPjxjaXJjbGUgY3g9IjQwIiBjeT0iMzIiIHI9IjIuNSIgZmlsbD0iI0Y1OUUwQiIvPjwvc3ZnPg==)](https://github.com/PwnKit-Labs/foxguard)
repos:
  - repo: https://github.com/PwnKit-Labs/foxguard
    rev: v0.3.2
    hooks:
      - id: foxguard
      - id: foxguard-secrets

Or run foxguard init to install a git hook directly.

foxguard auto-discovers .foxguard.yml from the scan path upward.

scan:
  baseline: .foxguard/baseline.json
  rules: ./semgrep-rules

secrets:
  baseline: .foxguard/secrets-baseline.json
  exclude_paths:
    - fixtures
    - testdata
  ignore_rules:
    - secret/github-token

Adding a rule is one struct implementing a trait. See CONTRIBUTING.md.


Built by PwnKit Labs and Doruk Tan Ozturk

Part of the open-source modern SOC

foxguard is one piece of a three-part open-source security stack:

  • pwnkit — AI agent pentester (detect)
  • foxguard — Rust security scanner (prevent)
  • opensoar — Python-native SOAR platform (respond)

MIT

联系我们 contact @ memedata.com