Repository navigation
Description
Problem
Part 1 of #1314, which is too large for one pull request (comment of 2026-11-05).
The DNS lookup of the egress check is not injectable. vet_addresses calls socket.getaddrinfo, and avet_addresses calls anyio.getaddrinfo [code: src/devops_cli/http/egress.py:133, :146]. A test that needs a name to resolve patches socket.getaddrinfo itself, through public_dns [code: tests/support/web.py:37] or scripted_resolver [code: tests/web_fakes.py:196]. #2437 deleted _resolve_host_ips, so every lookup of the egress check now passes through these two functions.
Expected
- One resolver seam sits under
vet_addressesandavet_addressesinhttp/egress.py. It has a Protocol, one place that supplies the real lookup, and a hook that installs another resolver. - One fake, one fixture and one contract suite hold the seam to the real lookup.
Acceptance criteria
-
http/egress.pyexposes a resolver Protocol that resolves a host and port togetaddrinfoanswers, sync and async, within a timeout for the async lookup. The real resolver callssocket.getaddrinfoandanyio.getaddrinfo. A hook installs another resolver and returns the previous one, and a reset restores the real one.vet_addressesandavet_addressesresolve only through it. -
tests/support/fakes/dns.pymaps names to addresses, can answer every name with one public address aspublic_dnsdoes, can script the answers of a name per lookup, can time out a name, and fails an unknown name with thesocket.gaierrorthe real lookup raises. It records each lookup. - A
dnsfixture installs the fake through the hook, removes it at teardown and returns it. The root conftest registers it once, and the process-state reset restores the real resolver. Until the directsocket.getaddrinfocallers are routed, the fixture also answerssocket.getaddrinfofrom the same fake, the stdlib fallback that docs/TESTING.md allows for stdlib edges. -
tests/http/, the mirror directory ofhttp/egress.py, holds the DNS contract suite. It runs each case against the fake and the real resolver. The real side resolves onlylocalhostand IP literals, which the hermetic floor lets through. Cases: a loopback name, an IP literal, an unknown name and a timeout. - ARCHITECTURE.md names the resolver seam.
- Each new test runs offline in under 1 s.
uv run devops cipasses.
Existing tool considered
Alternatives check of #1314 (2026-10-29): not-applicable, no tool found. A Protocol with one real implementation and one hook follows the keyring seam (config/os_keyring.py) and needs no new library.
Related
Parent: #1314. Part 2 is the HTTP entry point and fake; part 3 is the caller migration. The 44 test files that request public_dns and the 29 that use scripted_resolver move to the dns fixture with their packages in part 3, which then deletes public_dns and ScriptedResolver.
Activity
dan-petty commentedon Nov 6, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
refactorprefix of the title gives the type.(cli)scope of the title gives the scope.It is a prerequisite for testing the egress security system but does not itself fix a vulnerability or block a release.It makes the egress DNS check testable in isolation, which improves confidence in the security fix of #898.It adds a Protocol, a fake, a fixture, a contract suite, and a docs line across several files, but the scope is bounded.Both touch the vet_addresses path in http/egress.py, but #2437 deletes pre-flight resolve paths while the candidate adds an injectable DNS seam and fake for testing.dan-petty commentedon Nov 6, 2026
Answer from project standards, under the owner's instruction of 2026-11-05.
Question: Where does the DNS contract suite live? #1314 said
tests/core/.Answer: In
tests/http/test_dns_contract.py. The seam is inhttp/egress.pysince #2437 removed the DNS code ofcore/validation.py, and docs/TESTING.md (Layout) saystests/mirrors the package tree. I changed the criterion in the body.Question: Do the users of
public_dnsandscripted_resolvermove in this item?Answer: No. They still patch
socket.getaddrinfoand httpcore2 dials, and they move with their packages in #3758, which deletes both fixtures. Thednsfixture does what they do, and the two sets coexist until then.Rule: docs/TESTING.md (Layout; Until the migration ends) and the split of #1314.
chore(main): release 0.67.2 (#3778)
devops-cli-service commentedon Nov 6, 2026
Released in v0.67.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.67.2
devops-cli-service commentedon Nov 6, 2026
Live since 2026-11-06 08:16 UTC