@@ -6,7 +6,7 @@ import { createLogger } from '@sim/logger'
66import { toError } from '@sim/utils/errors'
77import * as ipaddr from 'ipaddr.js'
88import { Agent , type RequestInit as UndiciRequestInit , fetch as undiciFetch } from 'undici'
9- import { allowPrivateDatabaseHosts , isHosted } from '@/lib/core/config/env-flags'
9+ import { isHosted , isPrivateDatabaseHostsAllowed } from '@/lib/core/config/env-flags'
1010import { type ValidationResult , validateExternalUrl } from '@/lib/core/security/input-validation'
1111import { PayloadSizeLimitError } from '@/lib/core/utils/stream-limits'
1212
@@ -156,7 +156,7 @@ export async function validateUrlWithDNS(
156156 * on their private network (e.g. a Docker/Swarm service name that resolves to an
157157 * internal IP). The opt-in only bypasses the private/reserved/loopback block; DNS
158158 * is still resolved so the caller can pin the connection to the resolved IP. The
159- * bypass is never honored on the hosted platform (see {@link allowPrivateDatabaseHosts }).
159+ * bypass is never honored on the hosted platform (see {@link isPrivateDatabaseHostsAllowed }).
160160 *
161161 * @param host - The database hostname to validate
162162 * @param paramName - Name of the parameter for error messages
@@ -174,18 +174,22 @@ export async function validateDatabaseHost(
174174 const cleanHost =
175175 lowerHost . startsWith ( '[' ) && lowerHost . endsWith ( ']' ) ? lowerHost . slice ( 1 , - 1 ) : lowerHost
176176
177- if ( cleanHost === 'localhost' && ! allowPrivateDatabaseHosts ) {
177+ if ( cleanHost === 'localhost' && ! isPrivateDatabaseHostsAllowed ) {
178178 return { isValid : false , error : `${ paramName } cannot be localhost` }
179179 }
180180
181- if ( ipaddr . isValid ( cleanHost ) && isPrivateOrReservedIP ( cleanHost ) && ! allowPrivateDatabaseHosts ) {
181+ if (
182+ ipaddr . isValid ( cleanHost ) &&
183+ isPrivateOrReservedIP ( cleanHost ) &&
184+ ! isPrivateDatabaseHostsAllowed
185+ ) {
182186 return { isValid : false , error : `${ paramName } cannot be a private IP address` }
183187 }
184188
185189 try {
186190 const { address } = await dns . lookup ( cleanHost , { verbatim : true } )
187191
188- if ( isPrivateOrReservedIP ( address ) && ! allowPrivateDatabaseHosts ) {
192+ if ( isPrivateOrReservedIP ( address ) && ! isPrivateDatabaseHostsAllowed ) {
189193 logger . warn ( 'Database host resolves to blocked IP address' , {
190194 paramName,
191195 hostname : host ,
0 commit comments