Skip to content

nmap C→Rust — M1: core::output (normal / grepable / XML) - #8

Merged
kj299 merged 1 commit into
masterfrom
claude/m1-output
Jul 9, 2026
Merged

kj299 merged 1 commit into
masterfrom
claude/m1-output

Conversation

@kj299

@kj299 kj299 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

What this is

Milestone 1 module core::output — the Rust port of output.cc / xml.cc for the connect-scan surface. Three renderers over the pure ScanResults model, clock-free (time strings are injected, so rendering is deterministic and the differential harness can normalize timestamps).

Changes

  • render_normal — nmap's default human report: Nmap scan report for …, Host is up., Not shown: N closed tcp ports (conn-refused), and the aligned PORT/STATE/SERVICE table (only open/open|filtered shown; the rest summarized).
  • render_grepable (-oG) — Host:/Status: and Host:/Ports: lines with the portno/state/proto//service/// entry format.
  • render_xml (-oX) — nmaprun/host/status/address/ports/port/state/service + extraports + runstats, with xml_escape hardening hostnames/service names against injection (the class xml.cc handles — there's a dedicated escaping test).
  • Service names resolved via the nmap-services ServiceTable.

Verified — visual fidelity

Sample normal output matches nmap's format exactly:

Nmap scan report for scanme.nmap.org (45.33.32.156)
Host is up.
Not shown: 996 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
9929/tcp open  nping-echo
  • fmt + clippy(-D warnings) + 45 core tests (4 output tests incl. XML injection-escaping) + 8 sys tests + unsafe-audit (0) — green.

Deferred (noted)

Host-latency line ((0.05s latency)), and the service-detection/OS/script sections — later milestones.

Milestone 1 status

8/9 modules done. The only remaining module is cli — wiring argv → targets → ports → timing → connect_scan → output into the nmap-rs binary. After that, nmap-rs -sT <target> produces real nmap-style output, and the shared fuzz + C-nmap differential oracle closes the remaining gates.

🤖 Generated with Claude Code


Generated by Claude Code

Rust port of output.cc + xml.cc for the connect-scan surface. Pure, clock-free
(times injected -> deterministic + differential-normalizable):
- render_normal: nmap's default report — "Nmap scan report for ...", "Host is
  up.", "Not shown: N closed tcp ports (conn-refused)", and the aligned
  PORT/STATE/SERVICE table (only open/open|filtered shown; rest summarized).
- render_grepable (-oG): Host:/Status: and Host:/Ports: lines with the
  portno/state/proto//service/// entry format.
- render_xml (-oX): nmaprun/host/status/address/ports/port/state/service +
  extraports + runstats, with xml_escape hardening hostnames/service names
  against injection (defends the class xml.cc handles).
- Service names via the nmap-services ServiceTable.

Visual check matches nmap's normal format exactly (column alignment, Not shown,
report header). Gates: fmt + clippy(-D) + 45 core tests (4 output, incl. an XML
injection-escaping test) + 8 sys tests + unsafe-audit 0. progress: output ->
ported. Deferred: host latency line, service-detection/OS/script sections.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
@kj299
kj299 marked this pull request as ready for review July 9, 2026 21:31
@kj299
kj299 merged commit 966fa74 into master Jul 9, 2026
12 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants