refactor(security): ipaddr-free @sim/security/hostnames sub-export (removes urls.ts loopback dup)#5787
Conversation
…r-free) unwrapIpv6Brackets + isLoopbackHostname move to a new ipaddr-free sub-export so client code can share them without pulling ipaddr.js into the browser bundle. ssrf.ts re-exports both, so its server/desktop consumers are unchanged. This eliminates the duplicate isLoopbackHostname in apps/sim/lib/core/utils/urls.ts: urls.ts and its three client importers (mcp queries, oauth probe, oauth url-validation) now use the single shared definition.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview
Unit tests for the pure helpers move from Reviewed by Cursor Bugbot for commit 32bb5b3. Configure here. |
Greptile SummaryThis PR moves pure hostname checks into an
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "refactor: split pure host helpers into @..." | Re-trigger Greptile |
What
Follow-up to #5784 (the SSRF hardening PR, now merged). Completes the
@sim/security/ssrfconsolidation by splitting the pure host helpers into an ipaddr-free sub-export so the last duplicate can be removed.unwrapIpv6Brackets+isLoopbackHostnamenever touchipaddr.js, but they lived in@sim/security/ssrfwhose top line isimport * as ipaddr from 'ipaddr.js'. That's whyapps/sim/lib/core/utils/urls.ts— which is pulled into client bundles — kept its own copy ofisLoopbackHostname(importing the ssrf one would have draggedipaddr.jsinto the browser).Change
@sim/security/hostnames— pure, zero-dependency:unwrapIpv6Brackets,isLoopbackHostname.ssrf.tsimportsunwrapIpv6Bracketsfrom it and re-exports both, so every existing@sim/security/ssrfconsumer (desktop + server) is unchanged.urls.tsdrops its localLOCALHOST_HOSTNAMESset +isLoopbackHostname, and its three client importers (hooks/queries/mcp,mcp/oauth/probe,mcp/oauth/url-validation) now use the single shared definition — noipaddr.jsin the client bundle.hostnames.test.ts.Behavior is equivalent for every reachable
url.hostnameinput (bracketed IPv6[::1]→ stripped::1;localhost/127.0.0.1unchanged) — verified by direct execution.Testing
@sim/security106 · affected sim suites (urls + mcp/oauth) 45 · type-check (security + fullapps/sim) ·check:boundaries·check:utils·check:api-validation:strict· Biome — all green.