| Crates.io | libinjectionrs |
| lib.rs | libinjectionrs |
| version | 0.1.1 |
| created_at | 2025-09-03 14:22:42.739043+00 |
| updated_at | 2025-09-03 14:34:24.370083+00 |
| description | Rust port of libinjection - SQL/XSS injection detection library |
| homepage | |
| repository | https://github.com/saarw/libinjectionrs |
| max_upload_size | |
| id | 1822609 |
| size | 793,508 |
A vibe port (AI translation without manually reviewing much of the code) of the libinjection library from C to memory-safe Rust. Libinjection is a library for SQL injection and XSS attack detection in strings. The port was done with an original plan created with GPT-5 and then mostly executed with Claude Code.
SmallVeclibinjectionrs/
├── benches/ # Performance benchmarks
├── comparison-bin/ # Tools for comparing Rust vs C behavior
├── docs/ # Architecture and porting documentation
├── ffi-harness/ # C FFI testing harness
├── fuzz/ # Fuzzing targets and corpora
├── libinjection-c/ # Git submodule with original C library
├── libinjection-debug/ # Debug tools for comparing implementations
├── libinjectionrs/ # Main Rust library source code
└── scripts/ # Build and corpus generation scripts
cargo clippy --workspace --all-targets -- -A warnings
To get started with development, first fetch the git submodule containing the original C library:
git submodule update --init --recursive
use libinjectionrs::{detect_sqli, detect_xss};
// SQL injection detection
let input = b"1' OR '1'='1";
let result = detect_sqli(input);
if result.is_injection() {
println!("SQL injection detected: {:?}", result.fingerprint);
}
// XSS detection
let input = b"<script>alert('xss')</script>";
let result = detect_xss(input);
if result.is_injection() {
println!("XSS detected");
}
Scripts create fuzz corpuses: What the script does:
SQLi corpus: Extracts 50 SQL injection test cases from test-sqli-*.txt files
XSS corpus: Extracts 63 HTML/XSS test cases from test-html5-*.txt files
Deduplication: Uses SHA1 hashes to avoid duplicate entries
Proper naming: Prefixes seeded files with seed_sqli_ or seed_xss_
Usage:
./scripts/seed_fuzz_corpus.sh sqli # Seed SQLi corpus only
./scripts/seed_fuzz_corpus.sh xss # Seed XSS corpus only
./scripts/seed_fuzz_corpus.sh all # Seed both corpora
Licensed under the BSD 3-Clause License (LICENSE or https://opensource.org/licenses/BSD-3-Clause).
This project is a Rust port of libinjection, which is also licensed under the BSD 3-Clause License.