Skip to content

feat(std-net): add bounded port scan#115

Merged
joshcramer merged 10 commits into
mainfrom
feat/std-net-port-scan
Jun 7, 2026
Merged

feat(std-net): add bounded port scan#115
joshcramer merged 10 commits into
mainfrom
feat/std-net-port-scan

Conversation

@larimonious
Copy link
Copy Markdown
Contributor

@larimonious larimonious commented Jun 6, 2026

Summary

  • Adds bounded std/net.port_scan(host, ports, opts) for explicit TCP port arrays only.
  • Reuses std/net target policy and TCP probe behavior so private/special destinations stay guarded.
  • Keeps ping() ICMP-only with clearer ICMP-unavailable errors.
  • Makes reachable(host, opts?) useful by default: probes ICMP plus TCP ports 80/443, and treats tcp_ports as additional explicit TCP ports.

Verification

  • cargo fmt --check
  • cargo test --test std_net_tests -- --nocapture
  • cargo test
  • cargo build --profile dev-release
  • ./target/dev-release/ntnt docs --generate

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

This PR expands std/net with bounded TCP scanning and richer reachability behavior. It changes:

  • Adds port_scan(host, ports, opts) for explicit bounded TCP port arrays.
  • Updates reachable() to probe ICMP plus default TCP ports 80 and 443, with caller-provided extra ports.
  • Keeps ping() ICMP-only with clearer unavailable-backend errors.
  • Adds docs, examples, typechecker coverage, and std/net tests for the new behavior.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (9): Last reviewed commit: "test(std-net): allow closed reachable de..." | Re-trigger Greptile

Comment thread src/stdlib/net.rs
Comment thread src/stdlib/net.rs Outdated
Comment thread tests/std_net_tests.rs Outdated
@larimonious larimonious changed the title feat(std-net): add bounded port scan feat(std-net): add bounded port scan and CT subdomain discovery Jun 6, 2026
- Implement Linux ICMP ping parsing without TCP fallback
- Keep private/special target policy enforcement for ping
- Make port_scan unresolved-host errors describe the host, not the first port
- Update std/net tests for real ICMP behavior
@larimonious larimonious changed the title feat(std-net): add bounded port scan and CT subdomain discovery feat(std-net): add bounded port scan Jun 6, 2026
Comment thread src/stdlib/net.rs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends std/net with a bounded TCP port_scan() over explicit port arrays, and updates ping() to perform real ICMP-backed pings (without TCP fallback), with corresponding typechecker, tests, docs, and examples updates.

Changes:

  • Add std/net.port_scan(host, ports, opts?) with port-count and concurrency bounds plus target-policy enforcement.
  • Replace std/net.ping() stub behavior with a system ping-backed ICMP implementation and structured result parsing.
  • Update Rust integration tests, typechecker signatures, reference docs, and a new example to cover port_scan (and updated ping behavior).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/type_checker_tests.rs Adds port_scan to std/net signature acceptance/rejection typechecking coverage.
tests/std_net_tests.rs Updates ping behavior test and adds deterministic local open/closed port_scan tests.
src/typechecker.rs Registers the port_scan function signature in the std/net module signatures.
src/stdlib/net.rs Implements port_scan, restores ICMP-backed ping, and adds parsing/helpers/options for both.
examples/std_net_port_scan.tnt Adds an opt-in example demonstrating bounded port scanning.
docs/STDLIB_REFERENCE.md Documents the new port_scan API in the generated stdlib reference.
docs/AI_AGENT_GUIDE.md Updates std/net guide content and examples to include port_scan.
design-docs/dd-046-std-net.md Updates the design doc status dashboard and acceptance checklist for PR3 port scan.

Comment thread src/stdlib/net.rs
Comment thread src/stdlib/net.rs
Comment thread tests/std_net_tests.rs
- Resolve ping targets without formatting host:port strings so IPv6 literals work
- Gate system ICMP ping to Linux and report platform/system errors plainly
- Keep no-reply ICMP responses as structured ping results
- Refresh docs/tests for the corrected ICMP behavior
Probe ICMP and default TCP ports 80/443 in reachable(), while treating tcp_ports as additional explicit TCP ports. Keep ping() ICMP-only and update docs/tests for the new reachability semantics.
Make the reachable regression listener nonblocking with a timeout so the test fails normally instead of hanging if default TCP ports satisfy reachability first.
Comment thread tests/std_net_tests.rs Outdated
Exercise reachable's default 80/443 ports plus an extra tcp_ports entry without waiting on an accept helper. This keeps the regression test portable when local port 80 is already open.
Keep the reachable regression focused on default-plus-extra port selection without assuming ICMP or local TCP 80/443 is reachable on every CI platform.
@joshcramer joshcramer merged commit e917661 into main Jun 7, 2026
10 checks passed
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.

3 participants