feat(std-net): add bounded port scan#115
Merged
Merged
Conversation
Contributor
Greptile SummaryThis PR expands
Confidence Score: 5/5This looks safe to merge.
Reviews (9): Last reviewed commit: "test(std-net): allow closed reachable de..." | Re-trigger Greptile |
This reverts commit dd8f1e1.
- 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
There was a problem hiding this comment.
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 systemping-backed ICMP implementation and structured result parsing. - Update Rust integration tests, typechecker signatures, reference docs, and a new example to cover
port_scan(and updatedpingbehavior).
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. |
- 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.
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.
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.
Summary
std/net.port_scan(host, ports, opts)for explicit TCP port arrays only.ping()ICMP-only with clearer ICMP-unavailable errors.reachable(host, opts?)useful by default: probes ICMP plus TCP ports 80/443, and treatstcp_portsas additional explicit TCP ports.Verification
cargo fmt --checkcargo test --test std_net_tests -- --nocapturecargo testcargo build --profile dev-release./target/dev-release/ntnt docs --generate