Skip to content

net-guard

The egress classifier. Package @unset/infrastructure-net-guard. Plan §2 rule 13, as the folder comment states it: caller-influenced outbound HTTP goes through here. scripts/guards/egress.ts scans product trees for a dynamic fetch, the raw-client specifiers in RAW_CLIENT, and new WebSocket / new EventSource. exempt skips infrastructure/net-guard/ and test files. EGRESS_FILE_EXEMPTIONS names the path interfaces/pds-admin/pds.mjs. The file says the scan is lexical.

Owns

ModuleWhat it holds
infrastructure/net-guard/src/ranges.tsRANGES, the address classes classifyAddress uses.
infrastructure/net-guard/src/classify.tsclassifyAddress, isInternalName, normaliseHost.
infrastructure/net-guard/src/resolve.tsresolveVetted, pinnedLookup, NetGuardError.
infrastructure/net-guard/src/dns.tsresolveTxt on node:dns/promises Resolver.
infrastructure/net-guard/src/policies.tsThe policies below.
infrastructure/net-guard/src/request.tscreateNetGuard.
infrastructure/net-guard/src/libraryFetch.tslibraryFetch and guardedFetch, a fetch shape over the guard.
infrastructure/net-guard/src/remote.fake.tsTest double. Not exported from index.ts.

Policies policies.ts exports:

ExportValue
plckind: "fixed", host plc.directory
atprotokind: "public"
internalPolicyBuilds a kind: "internal" policy from exact http(s) origins
objectStore(origin)internalPolicy("object-store", [origin]), one exact internal origin passed in by the caller

localPlc is a dead export, ADR 0023, decided (0001 log), acceptance pending.

checkRequest in request.ts allows PUT only on a kind: "internal" policy and GET and POST on any; any other method throws TypeError.

request.ts refuses status 301, 302, 303, 307 and 308 with egress.redirect. resolveVetted classifies every answer (classifyAddress) and pinnedLookup returns only the addresses it was given. infrastructure/postgres/config.ts calls classifyAddress for PG_SSLMODE=disable.

NetGuardSettings.onRequest is typed so the event carries the policy name, status, timing and byte count. The type has no host, URL or address field.

May import

The net-guard row, not the infrastructure row. No shared/, no domains/, no seal.

Declared in infrastructure/net-guard/package.json: undici 8.12.2. request.ts imports Agent, buildConnector and request from it.

vendor-sdk-one-adapter confines undici to this folder. net-guard-leaf is the same set for non-test files, plus fast-check and vitest for a *.test.ts.

Entry points

RolePath
Package export .infrastructure/net-guard/index.ts
CompositioncreateNetGuard in interfaces/web/src/lib/server/compose.ts

No main.ts and no Compose service for this package. libraryFetch is what infrastructure/pds passes the OAuth client (oauth-client.ts option fetch).

Data

No schema, role or table. infrastructure/postgres/config.ts is the other production caller of classifyAddress, for whether PG_SSLMODE=disable may name that host.