Skip to content

Commit cccbd61

Browse files
committed
moved util
1 parent 53b63f8 commit cccbd61

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

apps/sim/lib/core/security/input-validation.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,22 +1004,3 @@ export function validateGoogleCalendarId(
10041004

10051005
return { isValid: true, sanitized: value }
10061006
}
1007-
1008-
/**
1009-
* Escapes a value for use in single-quoted SQL string contexts
1010-
*
1011-
* Escapes single quotes by doubling them (SQL standard: `'` → `''`).
1012-
* This prevents SQL injection because `''` inside a single-quoted string
1013-
* represents a literal quote character, keeping the entire value as one string.
1014-
*
1015-
* @param value - The value to escape
1016-
* @param maxLength - Maximum length allowed (default: 63)
1017-
* @returns The escaped value safe for single-quoted SQL strings
1018-
* @throws Error if value is empty or exceeds maxLength
1019-
*/
1020-
export function escapeSqlString(value: string, maxLength = 63): string {
1021-
if (!value || value.length > maxLength) {
1022-
throw new Error(`Invalid value: ${value}`)
1023-
}
1024-
return value.replace(/'/g, "''")
1025-
}

apps/sim/tools/supabase/introspect.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createLogger } from '@sim/logger'
2-
import { escapeSqlString } from '@/lib/core/security/input-validation'
32
import type {
43
SupabaseColumnSchema,
54
SupabaseIntrospectParams,
@@ -148,6 +147,16 @@ SELECT json_build_object(
148147
) AS result;
149148
`
150149

150+
/**
151+
* Escapes a value for single-quoted SQL strings by doubling single quotes
152+
*/
153+
function escapeSqlString(value: string): string {
154+
if (!value || value.length > 63) {
155+
throw new Error(`Invalid value: ${value}`)
156+
}
157+
return value.replace(/'/g, "''")
158+
}
159+
151160
/**
152161
* SQL query filtered by specific schema
153162
*/

0 commit comments

Comments
 (0)