Skip to content

Commit 2fc8833

Browse files
Bill Leoutsakoscursoragent
authored andcommitted
Support IPv6 loopback in E2E database guard
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent dda8221 commit 2fc8833

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

apps/sim/lib/billing/stripe-client-config.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ const guardedEnvironment: StripeClientConfigEnvironment = {
1919
describe('isGuardedE2eDatabaseUrl', () => {
2020
it('accepts only loopback sim_e2e databases', () => {
2121
expect(isGuardedE2eDatabaseUrl(guardedEnvironment.DATABASE_URL)).toBe(true)
22+
expect(isGuardedE2eDatabaseUrl('postgresql://sim:sim@[::1]:5432/sim_e2e_config_test')).toBe(
23+
true
24+
)
2225
expect(isGuardedE2eDatabaseUrl('postgresql://db.example.com/sim_e2e_config_test')).toBe(false)
2326
expect(isGuardedE2eDatabaseUrl('postgresql://127.0.0.1/sim')).toBe(false)
2427
})

apps/sim/lib/billing/stripe-client-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function isGuardedE2eDatabaseUrl(databaseUrl: string | undefined): boolea
5252

5353
function isLoopbackHostname(hostname: string): boolean {
5454
const normalized = hostname.toLowerCase()
55-
if (normalized === 'localhost') return true
55+
if (normalized === 'localhost' || normalized === '::1' || normalized === '[::1]') return true
5656

5757
const octets = normalized.split('.')
5858
return (

0 commit comments

Comments
 (0)