2025-06-25 00:24:05 +02:00
# Nyx
2025-06-16 23:47:50 +02:00
2025-06-25 00:24:05 +02:00
**Nyx** is a lightweight, Rust‑ native command‑ line tool that detects potentially dangerous code patterns across several programming languages. It combines the accuracy of [`tree‑ sitter` ](https://tree-sitter.github.io/ ) parsing with a curated rule set and an optional SQLite‑ backed index to deliver fast, repeatable scans on projects of any size.
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
> **Project status – Alpha**
> Nyx is under active development. The public interface, rule set, and output formats may change without notice while we stabilize the core. Please pin exact versions in production environments.
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
---
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
## Key Capabilities
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
| Capability | Description |
|------------------------------|-------------------------------------------------------------------------------------------|
| Multi‑ language support | Rust, C, C++, Java, Go, PHP, Python, Ruby, TypeScript, JavaScript |
| AST‑ level pattern matching | Language‑ specific queries written against precise parse trees |
| Incremental indexing | SQLite database stores file hashes and previous findings to skip unchanged files |
| Parallel execution | File walking and rule execution run concurrently; defaults scale with available CPU cores |
| Configurable scan parameters | Exclude directories, set maximum file size, tune worker threads, limit output, and more |
| Multiple output formats | Human‑ readable console view (default) and machine‑ readable JSON / CSV / SARIF (roadmap) |
---
2025-06-17 11:20:19 +02:00
## Installation
2025-06-25 00:24:05 +02:00
### Build from source
2025-06-17 11:20:19 +02:00
```bash
2025-06-25 00:24:05 +02:00
$ git clone https://github.com/< your ‑ org > /nyx.git
$ cd nyx
$ cargo build --release
# optional – copy the binary into PATH
$ cargo install --path .
2025-06-17 11:20:19 +02:00
```
2025-06-25 00:24:05 +02:00
Nyx targets **stable Rust 1.78 or later** .
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
---
## Quick Start
2025-06-17 11:20:19 +02:00
```bash
2025-06-25 00:24:05 +02:00
# Scan the current directory (creates/uses an index automatically)
$ nyx scan
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
# Scan a specific path and emit JSON
$ nyx scan ./server --format json
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
# Perform an ad‑ hoc scan without touching the index
$ nyx scan --no-index
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
# Restrict results to high‑ severity findings
$ nyx scan --high-only
2025-06-17 11:20:19 +02:00
```
2025-06-25 00:24:05 +02:00
### Index Management
2025-06-17 11:20:19 +02:00
```bash
2025-06-25 00:24:05 +02:00
# Create or rebuild an index
$ nyx index build [PATH] [--force]
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
# Display index metadata (size, modified date, etc.)
$ nyx index status [PATH]
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
# List all indexed projects (add -v for detailed view)
$ nyx list [-v]
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
# Remove a single project or purge all indexes
$ nyx clean < PROJECT_NAME >
$ nyx clean --all
```
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
---
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
## Configuration Overview
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
Nyx merges a default configuration file (`nyx.conf` ) with user overrides (`nyx.local` ). Both live in the platform‑ specific configuration directory shown below.
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
| Platform | Directory |
|---------------|-----------------------------------|
| Linux / macOS | `~/.config/nyx/` |
| Windows | `%APPDATA%\ecpeter23\nyx\config\` |
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
Minimal example (`nyx.local` ):
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
```toml
[scanner]
min_severity = "Medium"
follow_symlinks = true
excluded_extensions = ["mp3", "mp4"]
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
[output]
default_format = "json"
max_results = 200
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
[performance]
worker_threads = 8 # 0 = auto‑ detect
batch_size = 200
channel_multiplier = 2
```
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
A fully documented `nyx.conf` is generated automatically on first run.
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
---
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
## Architecture in Brief
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
1. **File enumeration** – A highly parallel walker applies ignore rules, size limits, and user exclusions.
2. **Parsing** – Supported files are parsed into ASTs via the appropriate `tree‑ sitter` grammar.
3. **Rule execution** – Each language ships with a dedicated rule set expressed as `tree‑ sitter` queries. Matches are classified into three severity levels (`High` , `Medium` , `Low` ).
4. **Indexing (optional)** – File digests and findings are stored in SQLite. Later scans skip files whose content and modification time are unchanged.
5. **Reporting** – Results are grouped by file and emitted to the console or serialized in the requested format.
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
---
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
## Roadmap
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
| Area | Planned Improvements |
|------------------------|---------------------------------------------------------------------------|
| Control‑ flow analysis | Generation of CFGs for deeper reasoning about execution paths |
| Taint tracking | Intra‑ / inter‑ procedural tracing of untrusted data from sources to sinks |
| Output formats | Full SARIF 2.1.0, JUnit XML, HTML report generator |
| Rule updates | Remote rule feed with signature verification |
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
Community feedback will help shape priorities; please open an issue to discuss proposed changes.
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
---
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
## Contributing
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
Pull requests are welcome. To contribute:
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
1. Fork the repository and create a feature branch.
2. Adhere to `rustfmt` and ensure `cargo clippy --all -- -D warnings` passes.
3. Add unit and/or integration tests where applicable (`cargo test` should remain green).
4. Submit a concise, well‑ documented pull request.
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
See `CONTRIBUTING.md` for full guidelines.
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
---
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
## License
2025-06-17 11:20:19 +02:00
2025-06-25 00:24:05 +02:00
Nyx is dual‑ licensed under **Apache‑ 2.0** and **MIT** . You may choose either license.