Repository navigation
feat(api): operator-configured private-host exception for the Jev client - #808
Conversation
The Jev client dials through netguard's SSRF-safe HTTP client, which refuses any hostname resolving to a private/internal address — so an instance that hosts its own Jev-compatible gateway on an internal address (e.g. an in-cluster gateway behind a ClusterIP) can never call it: every request is refused client-side. This mirrors the existing PLUGIN_FETCH_PRIVATE_HOSTS opt-in for the plugin fetch client: a new JEV_PRIVATE_HOSTS env var (config.Jev. PrivateHosts, Helm api.jev.privateHosts) lists exact hostnames the Jev client may reach on a private address. The set flows through jev.New / ClientForProject into netguard.NewSafeHTTPClientWithPrivateHosts and into the request context (netguard.WithAllowedPrivateHosts), so every Jev consumer — TestJevConfig, autofill, auto-assign, automation jev_condition, auto-agent resolution — is covered at the single point where its client is built. netguard's two-key contract is preserved: the shared automation consumer client carries the set, but call_api keeps its full guard because its requests never name the host in their context. With no hosts configured the guard stays strict: loopback, link-local and cloud metadata addresses stay blocked even for listed hosts.
There was a problem hiding this comment.
Important
call_api does not actually keep its full guard: it shares one pooled transport with the Jev client, so a connection opened by a Jev request lets an unkeyed call_api request to the same operator-listed host skip the dial check.
Approach: sound — mirrors the existing PLUGIN_FETCH_PRIVATE_HOSTS opt-in, and routing every consumer through ClientForProject keeps the set in one place.
Reviewed changes
- Config plumbing —
JEV_PRIVATE_HOSTSis parsed intoconfig.JevConfig.PrivateHostsand carried through compose, the Helm chart (api.jev.privateHosts), both.env.examplefiles and the deploy README. - Client construction —
jev.New/ClientForProjectaccept the operator set, buildnetguard.NewSafeHTTPClientWithPrivateHosts, and attach the set to each request's context so the dialer opens only for the listed hosts. - Consumers — autofill, auto-assign, automation
jev_condition, auto-agent resolution andTestJevConfigall pass the set, and bootstrap rebuilds the automation consumer's shared outbound client with it. - Tests — env parsing, client-set retention and context wrapping are covered, and the existing loopback-refusal test still proves the default guard.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…d the dial check resolveJevAnswer swapped in the automation consumer's shared outbound client, which since the JEV_PRIVATE_HOSTS wiring carried a transport whose dialer opens for operator-listed private hosts. The netguard check lives in dialContext, but transports pool idle connections: once a keyed Jev request opened a connection to a listed host:port, a later unkeyed call_api request to the same host:port reused it without ever dialing — reaching the private address with no context key, the project-admin-authored path the guard exists to fence off. Split the wiring: the consumer's shared client returns to its constructor default (netguard.NewSafeHTTPClient, strict), and Jev rides a dedicated, test-only jevHTTPClient — the per-project client's own transport (built with the operator set) serves production. E2E harnesses point Jev at the local test server through the dedicated setter; call_api keeps WithHTTPClient for its own loopback needs. Reported by pullfrog review on Paca-AI#808.
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — the fix confines the private-host exception to the transport each Jev client owns, so call_api keeps its strict dialer without giving up the operator opt-in for Jev.
Reviewed changes
- Automation consumer transport split —
AutomationConsumergained a dedicated, test-onlyjevHTTPClient;resolveJevAnsweruses it only when set and otherwise resolves through the per-project client built fromJEV_PRIVATE_HOSTS. bootstrapwiring reverted — the automation consumer's sharedhttpClientis back to itsnetguard.NewSafeHTTPClientdefault, so pool reuse can no longer carry an unkeyedcall_apirequest to an operator-listed private host.- Harness updates — the worker Jev tests and both e2e automation harnesses now wire
WithJevHTTPClientinstead ofWithHTTPClient, keeping the localhttptest.Serverreachable without sharing call_api's transport.
The prior review's pooled-connection concern is fully addressed by ddec3af: call_api and Jev no longer share a transport in production, and the dedicated override is unavailable outside test wiring. go build ./..., go vet, and the worker/jev/netguard/config test suites pass at this head.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Problem
The Jev client (autofill, auto-assign, automation
jev_conditionnodes, auto-agent resolution, andPOST /projects/:id/jev-config/test) dials throughnetguard.NewSafeHTTPClient, an SSRF guard that refuses any hostname resolving to a private/internal address (RFC 1918, loopback, link-local, CGNAT, IPv6 ULA/transition literals).For deployments that host their own Jev-compatible gateway on an internal address (e.g. an in-cluster gateway behind a ClusterIP), every Jev request is refused client-side before it reaches the network — regardless of the project's stored base URL.
Solution
Mirrors the existing operator opt-in for the plugin fetch client (
PLUGIN_FETCH_PRIVATE_HOSTS→netguard.NewPrivateHosts→NewSafeHTTPClientWithPrivateHosts):JEV_PRIVATE_HOSTSenv var (config.JevConfig.PrivateHosts, comma-separated exact hostnames, empty by default). Also plumbed throughdocker-compose.prod.yml, the Helm chart (api.jev.privateHosts) and both.env.examplefiles.jev.New/jev.ClientForProjecttake the operator's set and build the client withnetguard.NewSafeHTTPClientWithPrivateHosts; the client puts the allowance on each request's context (netguard.WithAllowedPrivateHosts), mirroring how the plugin runtime does it forpaca.fetch. Because every Jev consumer builds its client through this single construction path, all of them are covered — no per-consumer overrides.jev_conditionpath swaps in the consumer's shared outbound client, so that client is built with the same set in bootstrap.call_apikeeps its full guard: the dialer only opens when the request context names the host, whichcall_apinever does.Behavior
NewSafeHTTPClientWithPrivateHostswith a nil set isNewSafeHTTPClient).netguardblocks stays blocked, and the dial stays pinned to the IP it just validated.Tests
TestLoad_JevPrivateHosts— env parsing (default empty; comma/whitespace list).TestNew_PrivateHosts— the configured set is kept on the client, nil leaves it off (dial-side set semantics are covered by netguard's own tests).TestSystemOne_PrivateHostExceptionRidesOnRequestContext— the allowance reaches the transport only via the request context, and only when hosts are configured (netguard's second key).TestSystemOne_RejectsPrivateAddress(existing) still passes, proving the default client keeps refusing a loopback destination.