@@ -176,51 +176,6 @@ final class MainContentCoordinator: ObservableObject {
176176 options: . caseInsensitive
177177 )
178178
179- // MARK: - Write Query Detection
180-
181- /// Write-operation SQL prefixes blocked in read-only mode
182- private static let writeQueryPrefixes : [ String ] = [
183- " INSERT " , " UPDATE " , " DELETE " , " REPLACE " ,
184- " DROP " , " TRUNCATE " , " ALTER " , " CREATE " ,
185- " RENAME " , " GRANT " , " REVOKE " ,
186- ]
187-
188- /// Check if a SQL statement is a write operation (modifies data or schema)
189- func isWriteQuery( _ sql: String ) -> Bool {
190- let uppercased = sql. uppercased ( ) . trimmingCharacters ( in: . whitespacesAndNewlines)
191- return Self . writeQueryPrefixes. contains { uppercased. hasPrefix ( $0) }
192- }
193-
194- // MARK: - Dangerous Query Detection
195-
196- /// Pre-compiled regex for detecting WHERE clause in DELETE queries (avoids per-call compilation)
197- private static let whereClauseRegex = try ? NSRegularExpression ( pattern: " \\ sWHERE \\ s " , options: [ ] )
198-
199- /// Check if a query is potentially dangerous (DROP, TRUNCATE, DELETE without WHERE)
200- func isDangerousQuery( _ sql: String ) -> Bool {
201- let uppercased = sql. uppercased ( ) . trimmingCharacters ( in: . whitespacesAndNewlines)
202-
203- // Check for DROP
204- if uppercased. hasPrefix ( " DROP " ) {
205- return true
206- }
207-
208- // Check for TRUNCATE
209- if uppercased. hasPrefix ( " TRUNCATE " ) {
210- return true
211- }
212-
213- // Check for DELETE without WHERE clause
214- if uppercased. hasPrefix ( " DELETE " ) {
215- // Check if there's a WHERE clause (handle any whitespace: space, tab, newline)
216- let range = NSRange ( uppercased. startIndex... , in: uppercased)
217- let hasWhere = Self . whereClauseRegex? . firstMatch ( in: uppercased, options: [ ] , range: range) != nil
218- return !hasWhere
219- }
220-
221- return false
222- }
223-
224179 // MARK: - Query Execution
225180
226181 func runQuery( ) {
0 commit comments