Skip to content

nmap C→Rust — M1: connect_scan (the scan driver) - #7

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

kj299 merged 1 commit into
masterfrom
claude/m1-connect-scan

Conversation

@kj299

@kj299 kj299 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

What this is

Milestone 1 module connect_scan — the driver that ties targets + ports + timing + sys::net into an actual unprivileged TCP connect scan. The analog of scan_engine_connect.cc's job (minus raw-packet congestion control, which the MVP replaces with simple bounded parallelism). This is the point where the MVP becomes a working scanner.

Changes

  • connect_scan(targets, config) -> ScanResults — per host, probes every requested TCP port via net::tcp_connect with a bounded in-flight window (prime + refill over a tokio JoinSet; max_parallelism: 0 ⇒ default cap of 100 so a big port range can't exhaust fds). Collects into the pure ScanResults model; a host is Up if any port answered (open/closed); ports are sorted for deterministic output.
  • On tokio's safe task API — still 0 unsafe in sys.

Verified — end to end

A real smoke (resolve + scan against a live loopback listener) shows the full pipeline working:

resolve_host(localhost) = [127.0.0.1]
host 127.0.0.1 is Up
  35485/tcp open    (syn-ack)
  35486/tcp closed  (conn-refused)
  65000/tcp closed  (conn-refused)
  • fmt + clippy(-D warnings) + 8 sys tests (open/closed detection, parallelism-bound refill, verdict branches; real-I/O tests #[cfg_attr(miri, ignore)]) + 41 core tests + unsafe-audit (0) — green.

Milestone 1 status

7/9 modules done. Remaining: core::output (normal/grep/XML rendering) then cli (wire targets → ports → timing → connect_scan → output into the binary), plus the shared fuzz + C-nmap differential oracle.

🤖 Generated with Claude Code


Generated by Claude Code

Ties the pieces into an actual unprivileged TCP connect scan (the analog of
scan_engine_connect.cc, minus raw congestion control):
- connect_scan(targets, cfg) -> ScanResults: per host, probes every TCP port via
  net::tcp_connect with a bounded in-flight window (prime + refill over a
  tokio JoinSet; max_parallelism 0 -> default cap). Collects into the pure
  ScanResults model; host is Up if any port answered (open/closed); ports sorted.
- On tokio's safe task API — still 0 unsafe in sys.

End-to-end smoke (resolve_host + connect_scan against a live loopback listener):
open port -> open/syn-ack, unbound -> closed/conn-refused, host Up. The MVP scan
works end to end.

Gates: fmt + clippy(-D) + 8 sys tests (open/closed detect, parallelism bound,
I/O tests miri-ignored) + 41 core tests + unsafe-audit 0. progress:
connect_scan -> ported.

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:08
@kj299
kj299 merged commit 9cb0f64 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