| 28 | |
| 29 | impl SqlInjectionDetector { |
| 30 | pub fn new() -> Self { |
| 31 | let mut dangerous_functions = HashSet::new(); |
| 32 | dangerous_functions.insert("exec".to_string()); |
| 33 | dangerous_functions.insert("execute".to_string()); |
| 34 | dangerous_functions.insert("sp_executesql".to_string()); |
| 35 | dangerous_functions.insert("xp_cmdshell".to_string()); |
| 36 | dangerous_functions.insert("eval".to_string()); |
| 37 | dangerous_functions.insert("system".to_string()); |
| 38 | dangerous_functions.insert("shell".to_string()); |
| 39 | dangerous_functions.insert("cmd".to_string()); |
| 40 | |
| 41 | Self { |
| 42 | max_depth: 10, |
| 43 | max_statements: 3, |
| 44 | max_unions: 5, |
| 45 | dangerous_functions, |
| 46 | allowed_table_patterns: HashSet::new(), |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// Analyze SQL query for injection attempts using AST-based detection |
| 51 | pub fn analyze_query(&self, query: &str) -> Result<SqlAnalysisResult, PgSqliteError> { |