MCPcopy Index your code
hub / github.com/simstudioai/sim / validateQuery

Function validateQuery

apps/sim/app/api/tools/mysql/utils.ts:67–80  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

65}
66
67export function validateQuery(query: string): { isValid: boolean; error?: string } {
68 const trimmedQuery = query.trim().toLowerCase()
69
70 const allowedStatements = /^(select|insert|update|delete|with|show|describe|explain)\s+/i
71 if (!allowedStatements.test(trimmedQuery)) {
72 return {
73 isValid: false,
74 error:
75 'Only SELECT, INSERT, UPDATE, DELETE, WITH, SHOW, DESCRIBE, and EXPLAIN statements are allowed',
76 }
77 }
78
79 return { isValid: true }
80}
81
82export function buildInsertQuery(table: string, data: Record<string, unknown>) {
83 const sanitizedTable = sanitizeIdentifier(table)

Callers 2

route.tsFile · 0.90
route.tsFile · 0.90

Calls 1

testMethod · 0.80

Tested by

no test coverage detected