fix(home-assistant): respect OOMOL_CONNECT_ALLOW_PRIVATE_NETWORK - #220
Conversation
Home Assistant instances on a LAN (e.g. 10.0.0.5) were rejected by the SSRF
egress guard even when the deployment set OOMOL_CONNECT_ALLOW_PRIVATE_NETWORK,
because the provider's executor definition never passed allowPrivateNetwork to
defineProviderExecutors. Without that opt-in the runtime falls back to the
shared public-only providerFetch, so the deployment flag had no effect for
Home Assistant.
Pass allowPrivateNetwork: isPrivateNetworkAccessAllowed, matching the 26 other
providers that already wire it.
Default behavior is unchanged: with the flag unset, private targets stay
blocked. Loopback, link-local, and cloud-metadata targets remain blocked in
both states.
Cover the opt-in beside the shared module in provider-runtime.test.ts, per
AGENTS.md ("Keep open-source-only shared-infrastructure tests beside the
shared module rather than inside a provider directory").
Summary by CodeRabbit
WalkthroughHome Assistant executors now set 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/providers/provider-runtime.test.ts (1)
142-150: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDefine one named executor test-context interface.
src/providers/provider-runtime.test.ts#L142-L150: replace the inline generic with the shared interface.src/providers/provider-runtime.test.ts#L162-L171: reuse that interface.src/providers/provider-runtime.test.ts#L181-L190: reuse that interface.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/provider-runtime.test.ts` around lines 142 - 150, Define one named executor test-context interface for the fetcher context, then replace the inline generic at src/providers/provider-runtime.test.ts lines 142-150 and reuse that interface at lines 162-171 and 181-190 when calling defineProviderExecutors.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/providers/provider-runtime.test.ts`:
- Around line 142-150: Define one named executor test-context interface for the
fetcher context, then replace the inline generic at
src/providers/provider-runtime.test.ts lines 142-150 and reuse that interface at
lines 162-171 and 181-190 when calling defineProviderExecutors.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7441883b-4799-4784-bec9-eee73d775548
📒 Files selected for processing (2)
src/providers/home_assistant/executors.tssrc/providers/provider-runtime.test.ts
Summary
request URL must not target private or reserved IP addresses, even when the deployment setsOOMOL_CONNECT_ALLOW_PRIVATE_NETWORK.src/providers/home_assistant/executors.tsnever passedallowPrivateNetworktodefineProviderExecutors, so the flag had no effect for thisprovider.
Problem
defineProviderExecutorsbuilds a private-network-aware egress fetch only when a provider opts in; otherwise it falls back to the public-onlyproviderFetch. Home Assistant took that fallback, so the flag could never reach a192.168.x.xor10.x.x.xinstance — the self-hosted case it exists for.homeassistant.local:8123, the placeholder shown in the connection form, was unreachable for the same reason.Default behavior is unchanged: with the flag unset, private targets stay blocked. Loopback, link-local, and cloud-metadata targets stay blocked either way.
Scope
Only the executor needed wiring. Home Assistant has no
assertPublicHttpUrlcall site to thread the flag intoresolveHomeAssistantBaseUrlandvalidateHomeAssistantCredentialboth route through the provider-localnormalizeBaseUrl— and noproxy.registry.tsentry. MigratingnormalizeBaseUrlonto the sharedassertPublicHttpUrlis a separate change, not attempted here.Tests
Added to
src/providers/provider-runtime.test.tsrather than a provider-local file, per AGENTS.md: "Keep open-source-only shared-infrastructure tests beside the shared module rather than inside a provider directory." Three cases cover the shared opt-in path: default blocks a private target, an opted-in executor reaches it once the flag is enabled, and loopback stays blocked even then.Verification
npm run fix-check(clean) andnpm test— 57 files, 566 tests passing.