elicpeter/nyx

GitHub: elicpeter/nyx

Nyx 是一款本地优先的多语言静态安全扫描器,通过跨文件污点追踪分析帮助团队在开发和 CI 中发现并分类处理代码漏洞。

Stars: 14 | Forks: 2

nyx **一款具有浏览器 UI 的本地优先安全扫描器。扫描你的代码库并在浏览器中进行分类处理,无需云端服务,无需注册账号。** [![crates.io](https://img.shields.io/crates/v/nyx-scanner.svg)](https://crates.io/crates/nyx-scanner) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Rust 1.88+](https://img.shields.io/badge/rust-1.88%2B-orange)](https://www.rust-lang.org) [![CI](https://img.shields.io/github/actions/workflow/status/elicpeter/nyx/ci.yml?branch=master)](https://github.com/elicpeter/nyx/actions) [![Docs](https://img.shields.io/badge/docs-elicpeter.github.io%2Fnyx-blue)](https://elicpeter.github.io/nyx/)

Nyx UI walkthrough: empty Welcome state, kicking off a scan, the populated overview with Health Score, drilling into a HIGH finding's flow visualizer, then the triage flow

## 本地扫描,本地浏览 Nyx 对你的代码库运行跨语言的污点分析,然后将结果提供给绑定到 `127.0.0.1` 的 React UI。你将获得一个包含严重程度、证据以及逐步展示 **数据流可视化**(演示从 source → sanitizer → sink 的数据流)的发现列表。分类决策会持久化保存到 `.nyx/triage.json`,该文件会随你的代码一起提交,以便团队共享同一分类状态。 ``` cargo install nyx-scanner nyx scan # runs the analyzer, caches findings in .nyx/ nyx serve # opens http://localhost:9700 in your browser ``` 所有数据都保留在你的计算机上:仅绑定环回接口、强制 Host 头验证、所有变更操作均启用 CSRF 防护、无遥测数据、无登录要求。

Overview dashboard for a small JS app: Health Score C 78 with the five-component breakdown (Severity pressure, Confidence quality, Trend, Triage coverage, Regression resistance), 3 findings detected, OWASP A03 and A02 buckets, confidence distribution and issue category bars, top affected files

## UI 功能一览 | 页面 | 展示内容 | |---|---| | **Overview (概览)** | 仪表盘:按严重程度统计的发现数量、主要违规项、引擎配置摘要 | | **Findings (发现)** | 可浏览的列表,包含严重程度徽章、分类状态、规则过滤器和语言过滤器 | | **Finding detail (发现详情)** | 带编号步骤的路径可视化器(source → sanitizer → sink)、代码片段、证据、跨文件标记、分类下拉菜单 | | **Triage (分类)** | 批量更新状态(open、investigating、fixed、false_positive、accepted_risk、suppressed)、审计追踪、JSON 导入/导出 | | **Explorer (浏览器)** | 文件树,包含每个文件的符号列表和发现结果覆盖层 | | **Scans (扫描)** | 运行历史、指标、对比两次扫描以查看变化 | | **Rules (规则)** | 每种语言的内置和自定义规则;可从 UI 添加规则 | | **Config (配置)** | 实时配置编辑器;无需重启即可重新加载配置 | `nyx serve` 标志:`--port `(默认为 `9700`)、`--host `(仅限环回地址:`127.0.0.1`、`localhost` 或 `::1`)、`--no-browser`。有关持久化设置,请参阅 `nyx.conf` 中的 `[server]`,并参考 [Browser UI 指南](https://elicpeter.github.io/nyx/serve.html) 以获取逐页的 UI 导览和安全模型说明。 ## 用于 CI 的 CLI 同一个引擎可以在 CI 流水线中以无头模式运行。SARIF 输出可直接上传至 GitHub Code Scanning。

nyx scan console output: HIGH taint findings across a JS and Python file with source → sink arrows

``` # 在中危或更高严重级别使作业失败,输出 SARIF nyx scan --format sarif --fail-on MEDIUM > results.sarif # Ad-hoc JSON,无 index nyx scan ./server --format json --index off # 仅 AST 模式(最快;跳过 CFG + taint) nyx scan --mode ast # 引擎深度快捷设置:fast | balanced(默认) | deep # `deep` 添加 symex + demand-driven 反向 taint,以约 2-3 倍的开销换取更高的精度 nyx scan --engine-profile deep ``` 正向跨文件污点分析在所有配置下均可运行。Symex 和按需反向遍历是可选功能。你可以通过 `--engine-profile deep` 统一开启它们,也可以单独开启(`--symex`、`--backwards-analysis`)。有关完整的切换矩阵,请参阅 [CLI 参考](https://elicpeter.github.io/nyx/cli.html#engine-depth-profile)。 ### GitHub Action ``` - uses: elicpeter/nyx@v0.5.0 with: format: sarif fail-on: MEDIUM - uses: github/codeql-action/upload-sarif@v3 with: sarif_file: nyx-results.sarif ``` 输入参数:`path`、`version`、`format`(`sarif`|`json`|`console`)、`fail-on`、`args`、`token`。输出参数:`finding-count`、`sarif-file`、`exit-code`、`nyx-version`。支持 Linux 和 macOS 运行器(x86_64、ARM64)。 ## 安装 **Cargo (推荐):** ``` cargo install nyx-scanner ``` **预编译二进制文件:** 从 [Releases](https://github.com/elicpeter/nyx/releases) 获取适用于你平台的压缩包,使用 `SHA256SUMS` 进行验证(如果存在 detached `SHA256SUMS.asc` GPG 签名,也一并验证),解压缩后将 `nyx` 放入你的 `PATH`。 ``` # 可选:验证校验和文件的 GPG 签名(当 SHA256SUMS.asc 发布时) gpg --verify SHA256SUMS.asc SHA256SUMS sha256sum -c SHA256SUMS --ignore-missing unzip nyx-x86_64-unknown-linux-gnu.zip && chmod +x nyx && sudo mv nyx /usr/local/bin/ ``` **从源码构建:** ``` git clone https://github.com/elicpeter/nyx.git cd nyx && cargo build --release ``` 需要稳定的 Rust 1.88+ 版本。前端在构建时会被编译并嵌入到二进制文件中,因此无需为 `nyx serve` 进行单独的安装步骤。 ## 编程语言 所有 10 种语言均通过 tree-sitter 进行解析,并运行完整的分析流程,但规则深度和引擎覆盖范围并不均衡。在包含 433 个测试用例的语料库 [`tests/benchmark/ground_truth.json`](tests/benchmark/ground_truth.json) 中,有 9 种语言的基准 F1 分数达到了 100%,而 Go 为 94.1%,因此仅凭 F1 分数已无法区分层级。目前的层级划分反映了规则深度、受控 sink 覆盖率以及合成语料库未能完全测试的结构特性: | 层级 | 语言 | F1 | 适合作为 CI 门禁吗? | |---|---|---|---| | **Stable** | Python, JavaScript, TypeScript | 100% | 是 | | **Beta** | Java, PHP, Ruby, Rust, Go | 94.1% 到 100% | 是,需进行少量误报分类处理 | | **Preview** | C, C++ | 在合成语料库上为 100% | 否。目前已能追踪 STL 容器流、构建器链和内联类成员函数,但无法处理深层指针别名和函数指针。请配合 clang-tidy 或 Clang Static Analyzer 使用 | 总体规则级别的 F1:99.8% (P=0.995, R=1.000)。所有真实的 CVE 测试用例均已触发;唯一未解决的误报是 `go-safe-009`。各维度的详细信息及已知盲点请查阅 [语言成熟度页面](https://elicpeter.github.io/nyx/language-maturity.html)。 ### 经过真实 CVE 验证 该语料库还包含一小部分从已发布的安全公告中提取的漏洞/补丁对,因此基准的底线是由对真实漏洞的回归测试来保障的,而不仅仅是依赖合成的模拟数据。Nyx 能在漏洞文件上触发告警,并在每个漏洞对的补丁文件上输出零告警。 | CVE | 项目 | 语言 | 类别 | |---|---|---|---| | [CVE-2023-48022](https://nvd.nist.gov/vuln/detail/CVE-2023-48022) | Ray | Python | 命令注入 | | [CVE-2017-18342](https://nvd.nist.gov/vuln/detail/CVE-2017-18342) | PyYAML | Python | 反序列化 | | [CVE-2019-14939](https://nvd.nist.gov/vuln/detail/CVE-2019-14939) | mongo-express | JavaScript | 代码执行 (`eval`) | | [CVE-2025-64430](https://nvd.nist.gov/vuln/detail/CVE-2025-64430) | Parse Server | JavaScript | SSRF | | [CVE-2023-26159](https://nvd.nist.gov/vuln/detail/CVE-2023-26159) | follow-redirects | TypeScript | SSRF | | [CVE-2022-30323](https://nvd.nist.gov/vuln/detail/CVE-2022-30323) | hashicorp/go-getter | Go | 命令注入 | | [CVE-2024-31450](https://nvd.nist.gov/vuln/detail/CVE-2024-31450) | owncast | Go | 路径穿越 | | [CVE-2023-3188](https://nvd.nist.gov/vuln/detail/CVE-2023-3188) | owncast | Go | SSRF | | [CVE-2015-7501](https://nvd.nist.gov/vuln/detail/CVE-2015-7501) | Apache Commons Collections | Java | 反序列化 | | [CVE-2017-12629](https://nvd.nist.gov/vuln/detail/CVE-2017-12629) | Apache Solr | Java | 命令注入 | | [CVE-2013-0156](https://nvd.nist.gov/vuln/detail/CVE-2013-0156) | Ruby on Rails | Ruby | 反序列化 | | [CVE-2020-8130](https://nvd.nist.gov/vuln/detail/CVE-2020-8130) | Rake | Ruby | 命令注入 | | [CVE-2017-9841](https://nvd.nist.gov/vuln/detail/CVE-2017-9841) | PHPUnit | PHP | 代码执行 (`eval`) | | [CVE-2018-15133](https://nvd.nist.gov/vuln/detail/CVE-2018-15133) | Laravel | PHP | 反序列化 | | [CVE-2016-3714](https://nvd.nist.gov/vuln/detail/CVE-2016-3714) | ImageMagick (ImageTragick) | C | 命令注入 | | [CVE-2019-18634](https://nvd.nist.gov/vuln/detail/CVE-2019-18634) | sudo (pwfeedback) | C | 内存安全 | | [CVE-2019-13132](https://nvd.nist.gov/vuln/detail/CVE-2019-13132) | ZeroMQ libzmq | C++ | 内存安全 | | [CVE-2022-1941](https://nvd.nist.gov/vuln/detail/CVE-2022-1941) | Protocol Buffers | C++ | 内存安全 | 测试用例位于 [`tests/benchmark/cve_corpus/`](tests/benchmark/cve_corpus/) 目录下,并带有上游归属标头。