This directory contains comprehensive testing infrastructure for rustnmap, including comparison tests against nmap and standalone CLI validation tests.
- Update test expectations as nmap/rustnmap behavior changes
- Add new CLI options to rustnmap_test.sh as they are implemented
- Keep test suite coverage at 100% of defined test configurations
- Review generated reports in
benchmarks/reports/after test runs
- Tests require sudo privileges for raw socket operations
- The rustnmap and nmap binaries are already configured in
/etc/sudoers - 5-second delays between scans for reliability
- No external dependencies required for shell scripts
- Test configurations remain in TOML files for consistency
benchmarks/
├── README.md # This file
├── comparison_test.sh # rustnmap vs nmap comparison tests (41 tests)
├── rustnmap_test.sh # rustnmap CLI validation tests (104 tests)
├── test_configs/ # Test configuration TOML files
│ ├── basic_scan.toml
│ ├── service_detection.toml
│ ├── os_detection.toml
│ ├── advanced_scan.toml
│ ├── stealth_extended.toml
│ ├── timing_tests.toml
│ ├── output_formats.toml
│ └── multi_target.toml
├── logs/ # Test execution logs (gitignored)
├── reports/ # Generated test reports (gitignored)
└── test_outputs/ # Output files from format tests (gitignored)
| Feature | comparison_test.sh | rustnmap_test.sh |
|---|---|---|
| Purpose | Compare rustnmap vs nmap | Test rustnmap CLI only |
| Tests | 41 comparison tests | 104 CLI option tests |
| Coverage | Common scan types | ALL 85 CLI options |
| Focus | Functional parity | Comprehensive CLI validation |
| Output | Pass/fail comparison | Individual option validation |
# Default test target (scanme.nmap.org)
export TARGET_IP="${TARGET_IP:-45.33.32.156}"
# Alternate target (localhost for testing)
export ALT_TARGET="${ALT_TARGET:-127.0.0.1}"
# Custom ports
export TEST_PORTS="${TEST_PORTS:-22,80,113,443,8080}"cargo build --release# Comparison tests (rustnmap vs nmap)
./benchmarks/comparison_test.sh
# Standalone rustnmap CLI tests
./benchmarks/rustnmap_test.sh
# Custom target/ports
TARGET_IP=192.168.1.1 ./benchmarks/comparison_test.sh
TEST_PORTS="22,80,443" ./benchmarks/comparison_test.shCompares rustnmap output against nmap to verify functional parity.
# Run all 41 comparison tests
./benchmarks/comparison_test.sh
# Custom target/ports
TARGET_IP=192.168.1.1 ./benchmarks/comparison_test.sh
TEST_PORTS="22,80,443" ./benchmarks/comparison_test.sh| Category | Tests | Description |
|---|---|---|
| Basic Scans | 5 | SYN, Connect, UDP, Fast, Top Ports |
| Stealth Scans | 6 | FIN, NULL, XMAS, MAIMON, ACK, Window |
| Advanced Scans | 6 | Evasion techniques (decoy, source port, fragment) |
| Timing Templates | 6 | T0-T5 timing levels |
| Output Formats | 5 | Normal, XML, Grepable, JSON, List |
| Multi-Target | 5 | Range, hostlist, exclude, randomize |
| Service Detection | 4 | Version detection, intensity, aggressive |
| OS Detection | 4 | OS detection, limit, guess |
- Logs:
logs/comparison_*.log- Detailed execution logs - Reports:
reports/comparison_report_*.txt- Pass/fail summary
Each test compares:
- Port States: OPEN, CLOSED, FILTERED, UNFILTERED, OPEN|FILTERED
- Service Detection: Version information accuracy
- Performance: Execution time comparison
A test passes when both scanners produce equivalent port states.
Validates ALL 85 rustnmap CLI options across 12 categories.
# Run all 104 CLI tests
./benchmarks/rustnmap_test.sh
# Custom target
TARGET_IP=192.168.1.1 ./benchmarks/rustnmap_test.sh
# Custom ports
TEST_PORTS="22,80,443" ./benchmarks/rustnmap_test.sh| Category | CLI Options | Tests |
|---|---|---|
| 1. Target Specification | 5 | 5 |
| 2. Scan Types | 9 | 9 |
| 3. Port Specification | 6 | 7 |
| 4. Service/OS Detection | 6 | 8 |
| 5. Timing/Performance | 6 | 11 |
| 6. Firewall/IDS Evasion | 9 | 8 |
| 7. Output Formats | 18 | 21 |
| 8. Scripting (NSE) | 4 | 5 |
| 9. Miscellaneous | 9 | 9 |
| 10. Scan Management 2.0 | 14 | 8 |
| 11. Configuration | 2 | 2 |
| 12. Edge Cases/Validation | - | 11 |
Single IP, hostname, CIDR notation, range, multiple targets
-sS SYN, -sT Connect, -sU UDP, -sF FIN, -sN NULL, -sX XMAS, -sM MAIMON, -sA ACK, -sW Window
-p specific ports, -p- all ports, --exclude-port, --top-ports, -F fast scan, --protocol
-A aggressive, -sV service detection, --version-intensity (0-9), -O OS detection, --osscan-limit, --osscan-guess
-T0 through -T5 timing templates, --scan-delay, --min-parallelism, --max-parallelism, --min-rate, --max-rate
-D decoy, -S spoof IP, -e interface, -f fragment, -g source port, --data-length, --data-hex, --data-string
-oN/-oX/-oG/-oJ/-oA output files, --output-ndjson, --output-markdown, --output-script-kiddie, --no-output, --stream, --append-output, -v/-vv/-vvv verbose, -q quiet, -d/-dd/-ddd debug, --reasons, --open, --packet-trace, --if-list
--script, --script-args, --script-help, --script-updatedb
--traceroute, --traceroute-hops, -i input file, --randomize-hosts, --host-group-size, --ping-type, --disable-ping, --host-timeout, --print-urls
--list-profiles, --generate-profile, --validate-profile, --history, --history --target, --history --scan-type-filter, --history --since/--until, --history --db-path
--datadir, --dns-server
Invalid input validation (timing, intensity, MTU, port conflicts), boundary value tests
- Logs:
logs/rustnmap_test_*.log- Detailed execution logs - Reports:
reports/rustnmap_test_report_*.txt- Summary with pass/fail - Test Outputs:
test_outputs/- Generated output files (XML, JSON, etc.)
| Variable | Default | Description |
|---|---|---|
TARGET_IP |
45.33.32.156 | Primary test target (scanme.nmap.org) |
ALT_TARGET |
127.0.0.1 | Alternate target for local tests |
TEST_PORTS |
22,80,113,443,8080 | Ports to test |
RUSTNMAP_BIN |
./target/release/rustnmap | Path to rustnmap binary |
NMAP_BIN |
/usr/bin/nmap | Path to nmap binary (comparison tests only) |
comparison_test.sh: Tests are organized by suite functions. Add new tests to the appropriate function.
rustnmap_test.sh: Add tests to category functions:
run_test "Description" \
"sudo $RUSTNMAP_BIN --new-option value target"For development, comment out other test categories in main():
main() {
cargo build --release
# Only run specific category
test_timing_performance
# Generate report
}