Skip to content

docs(openspec): plan #2184 Use ipaddress for single-address egress checks - #3156

Merged
dan-petty merged 4 commits into
mainfrom
refactor/2184-the-egress-checks-take-their-non
Nov 2, 2026
Merged

dan-petty merged 4 commits into
mainfrom
refactor/2184-the-egress-checks-take-their-non

Conversation

@devops-cli-service

@devops-cli-service devops-cli-service Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Plans #2184

Plan for #2184. The egress checks in src/devops_cli/core/validation.py use a block list that copies the private module pydantic_ai._ssrf. This plan makes is_private_ip ask Python's ipaddress about each address (is_global, is_multicast). It keeps the rules that ipaddress lacks: NAT64 with all offsets, IPv4-compatible, ISATAP and the block 192.0.0.0/24, each with an RFC comment. A table test over the IANA registries pins the answers first. The block list stays for the overlap test of a range, because ipaddress has no public list. The table test holds it to is_global. No behavior changes, so there is no spec delta.

Change: openspec/changes/2184-the-egress-checks-take-their-non/

🤖 Generated with Claude Code

https://claude.ai/code/session_01PeiMDoPafqUWqpk1WxhaYW

Copy link
Copy Markdown
Owner

Review of the plan for #2184. CI is green. The premise holds: the constants are in config/constants.py and validation.py imports them. Using stdlib ipaddress fits rule 3. Findings, most important first:

  1. NAT64 is not covered by stdlib, and the plan deletes it. I ran this on the container's Python: ipaddress.ip_address("64:ff9b::c000:201").is_global is True, but that address embeds 192.0.2.1, a documentation address. ::ffff:10.0.0.1 and a 6to4 address do report non-global. ipaddress has ipv4_mapped, sixtofour and teredo, and no NAT64 (RFC 6052) property. Task 2.1 deletes CONST_NAT64_PREFIXES and CONST_ALL_EMBEDDED_OFFSETS. Without a NAT64 rule, the NAT64 form of a private address would pass the egress check. Keep the NAT64 rule (the 48, 56, 64 and 96 bit offsets) with an RFC 6052 comment, and add a table row for it. The proposal's "keep only ISATAP and IPv4-compatible" must change.
  2. Python version. The is_global and is_private tables changed between Python releases. Name the supported minimum in ## Feasibility, and check the table test on each supported version.
  3. Dependency. refactor(security): the egress checks read legacy numeric hosts with getaddrinfo and AI_NUMERICHOST, and the hand-written ipv4 parser goes #2152 is now closed, so the "deliver after refactor(security): the egress checks read legacy numeric hosts with getaddrinfo and AI_NUMERICHOST, and the hand-written ipv4 parser goes #2152" note can become a plain statement. Confirm that it merged and not that it was rejected, and rebase the plan on its parse_numeric_ip.
  4. Task list. Task 1.2 says "Write the table test first", but 1.1 already does. The grep check in 2.1 does not cover the helper names (_non_public_networks, _exhaustive_embedded_ipv4s, _standard_embedded_ipv4s, _embedded_ipv4s) that the proposal says are removed.
  5. Spec. Add a separate NAT64 scenario. Say what "same answer as is_global" means for loopback and link-local addresses.
  6. Tracking line. Remove the "Workflow follow-up" section in tasks.md (rule 8).

Related issues: #2184 (this plan's issue, open), #2152 (closed, same module), #1314 (open; one DNS seam for the private resolver, same code area).

Verdict: hold until finding 1 is fixed.


Generated by Claude Code

Copy link
Copy Markdown
Owner

Correction to my earlier review: finding 6 (remove the "Workflow follow-up" section) is wrong. openspec/config.yaml (tasks rules) says a change that alters code may end with the plain bullet "Pending a person: review the diff in tuicr (tuicr -r ..HEAD)." Keep it. My other findings stand, including the NAT64 gap.


Generated by Claude Code

The plan deleted the NAT64 rule, which ipaddress lacks, and listed
helpers that is_cloud_metadata_ip and the range test still read. It
cited a test path outside the mirror folder, a spec delta for a
refactor that keeps behavior, and a dependency on #2152 that is met.

The plan now asks ipaddress about each single address, keeps the NAT64,
IPv4-compatible, ISATAP and 192.0.0.0/24 rules with RFC comments, keeps
the block list for the range test, pins the answers with a table test
first, and drops the spec delta.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PeiMDoPafqUWqpk1WxhaYW
@dan-petty dan-petty changed the title docs(openspec): plan #2184 Use stdlib for non-public IP checks docs(openspec): plan #2184 Use ipaddress for single-address egress checks Nov 2, 2026

Copy link
Copy Markdown
Owner

Plan fixed at 56d727a. Findings of the review, checked against main (d312a98), not taken on trust:

  1. NAT64: real. is_global is True for 64:ff9b::c000:201. A probe that removed the NAT64 loop made 64:ff9b::a00:1 public and failed two tests in tests/core/test_validation.py. The plan keeps the rule with all offsets and adds a table row for the documentation address.
  2. Python version: the floor is 3.14 (pyproject.toml:10). I ran the probes on 3.14.6. Python 3.14.10 (the pin) is not installed here, so its is_global table is unverified. The table test pins the registry rows and fails in CI if a release changes one.
  3. refactor(security): the egress checks read legacy numeric hosts with getaddrinfo and AI_NUMERICHOST, and the hand-written ipv4 parser goes #2152: closed as completed, merged as refactor(security): read legacy numeric hosts with getaddrinfo #3128. parse_numeric_ip now uses getaddrinfo. The plan does not touch it. The dependency note is gone.
  4. Tasks: the duplicate "test first" task is gone. The deleted helpers are now kept, because is_cloud_metadata_ip reads _exhaustive_embedded_ipv4s and the range test reads _non_public_networks. The test path is tests/core/ (the mirror), not tests/.
  5. Spec: removed. The plan keeps behavior (is_non_public_ip gave the same answer on 58,242 probe addresses), so skip_specs: true.
  6. Tuicr bullet: kept, as your correction says.

New findings that change the plan:

  • A range needs the block list. ip_network('8.0.0.0/5').is_global and ip_network('64::/16').is_global are True, and the existing range tests refuse both. ipaddress has no public block list, so CONST_PRIVATE_NETWORKS stays for the range test, with a drift test against is_global.
  • is_global is True for multicast, 192.0.0.9 and 192.0.0.10. The plan adds is_multicast and keeps 192.0.0.0/24 refused, so the guard is not loosened.
  • The issue is stale: _enforce_non_private_ssrf and validate_url are gone (fix(security): remove pre-flight resolve paths for egress #2845), and pydantic-ai is at 2.59.0.
  • Criterion 1 cannot be met whole here. The grep of the issue also finds constants.py:2731 (the finish-reason maps, which copy private pydantic-ai maps). They are no address rule. The plan maps this criterion to pending-person.

For a person to decide: netaddr 1.3.0 publishes lists of not-globally-reachable networks and could replace the range list. It is not in uv.lock, and its is_global() has the same NAT64 gap. The plan does not add it.

Gap in tooling: body_problems in pull_form.py refuses a correct plan body. It needs a Closes #<issue> line, and a plan body has Plans #<issue>. This body would pass only with a Closes line, which would close the issue at the merge of the plan.


Generated by Claude Code

@dan-petty
dan-petty merged commit 0f50d71 into main Nov 2, 2026
20 checks passed
@dan-petty
dan-petty deleted the refactor/2184-the-egress-checks-take-their-non branch November 2, 2026 16:28
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