Repository navigation
nmap C→Rust — M1: cli (the MVP works end-to-end) - #9
Merged
Merged
Conversation
The capstone. Wires argv -> targets -> ports -> timing -> connect_scan -> output into the nmap-rs binary; all logic stays in core (pure) / sys (async I/O). - options: extend RunConfig + parse_args for the M1 CLI surface — -p (attached or separate), -oN/-oX/-oG <file|->, -6, -Pn, -sT; option-argument handling; unknown flags still recorded, not mis-parsed. - main.rs (#[tokio::main]): load nmap-services (searched paths / NMAP_RS_DATADIR), select ports (-p | top-1000 | 1-1024 fallback), resolve/expand targets (parse_target + sys::net::resolve_host, bounded by MAX_TARGETS), run connect_scan, re-attach hostnames, honor -Pn, render normal/XML/grepable to stdout or files. Typed errors + exit codes; no unwrap on user/net input. Live end-to-end verified: `nmap-rs -sT -p 22,80,8080,9999 127.0.0.1` reports 8080/tcp open http-proxy (name from nmap-services) and "Not shown: 3 closed tcp ports"; -oX/-oG and hostname resolution (localhost) all correct. Gates: fmt + clippy(-D) + 47 core tests + 8 sys tests + unsafe-audit 0 + supply-chain clean. All 9 M1 modules now ported. progress: cli -> ported. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
kj299
marked this pull request as ready for review
July 9, 2026 21:54
kj299
added a commit
that referenced
this pull request
Jul 10, 2026
The compounding step for Milestone 1 — patch PLAYBOOK/harnesses and append LESSONS.md with what the nmap MVP taught the kit. Each edit names the failure it prevents next time. LESSONS #6 — scan_c_flaws read only .c/.h and reported nmap's ~9.4k LOC of C++ (.cc) as "0 flaws". Extension set widened to cover C++ (fix already in tree from PR #2); now pinned with a self-test that iter_c_files yields .cc/.cpp/.hpp and ignores non-source. Phase 0: confirm the scanner reads the target's languages before believing a low count. LESSONS #7 — diff_run.py is case-granular, so an MVP that intentionally renders a subset of C output can't be diffed raw (every case diverges) or ledgered (the whole case goes blind). Documented the canonical-projection pattern: wrap both sides in a filter that emits only the semantic result, canonicalizing both representations so real regressions still break the match. Phase 4 gate 2. LESSONS #8 — Miri can't execute real I/O (tokio connect aborts under Miri). Split the pure decision (verdict) from the syscall and cfg(miri)-ignore the I/O tests, so "Miri can't run this" never becomes "no Miri coverage." Phase 4 gate 4. LESSONS #9 — the linear six-gate model implies every module needs a fuzz tick, but fuzzing is threat-model-scoped (parsers, not renderers/models). And `cargo fuzz run <t> seeds/<t>` writes discovered inputs back into the seeds dir. gen_fuzz_target.sh guidance now shows corpus/<t> seeds/<t> (writable, read-only) and scopes the gate. Phase 4 gate 3. Meta: 3 of 4 are the same shape as winlsof #2-#4 — a control that inspects less than its green checkmark implies; the defense (retrospective step 0: run every harness against the real target and eyeball what it inspected) held again. check-kit: all harness self-tests + skills integrity green. Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w Co-authored-by: Claude <[email protected]>
kj299
added a commit
that referenced
this pull request
Jul 19, 2026
The leaf every M4 packet parser stands on: read_u8/read_be_u16/u32/u64, read_array::<N>, take/peek/skip each return Result, never index out of range, never panic. checked_add on the offset stops a near-usize::MAX take() wrapping into a false in-bounds read; a failed read leaves the cursor unmoved. Replaces C's advance-a-pointer-and-trust-validate() pattern with a bounds check by construction. 19 tests (incl. exhaustive buf-len x take-len sweep), miri clean, forbid(unsafe). Differential/fuzz N/A for this leaf (LESSONS #9).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
The capstone of Milestone 1 — the
climodule that wiresargv → targets → ports → timing → connect_scan → outputinto thenmap-rsbinary.nmap-rs -sT <target>now produces real nmap-style output end to end. All logic stays incore(pure) /sys(async I/O); the CLI is thin.Changes
options— extendedRunConfig+parse_argsfor the M1 CLI surface:-p(attached-p22or separate-p 22),-oN/-oX/-oG <file|->,-6,-Pn,-sT, with option-argument handling. Unknown flags are still recorded, never mis-parsed.main.rs(#[tokio::main]) — loadsnmap-services(searched paths /NMAP_RS_DATADIR), selects ports (-p| top-1000 |1-1024fallback), resolves/expands targets (parse_target+sys::net::resolve_host, bounded byMAX_TARGETS), runsconnect_scan, re-attaches hostnames, honors-Pn, and renders normal/XML/grepable to stdout or files. Typed errors + exit codes; nounwrapon user/network input.Verified — live, end to end
-oX -emits proper nmap XML (withlocalhost→127.0.0.1resolution, extraports, runstats);-oG -emits the grepable form; service names come fromnmap-services.-D warnings) + 47 core tests + 8 sys tests + unsafe-audit (0) + supply-chain clean — green.Milestone 1: all 9 modules ported ✅
model · targets · options · log · ports · timing · net · connect_scan · output · cli. The MVP scanner is functional. Remaining M1 work: stand up the shared cargo-fuzz targets (target/port/services parsers) + the C-nmap differential oracle to formally close the fuzz/differential gate columns, then the M1 retrospective (which patches the kit — the non-negotiable compounding step).🤖 Generated with Claude Code
Generated by Claude Code