(
&self,
statement: &Statement,
analysis: &mut SqlAnalysisResult,
depth: usize,
original_query: &str
)
| 124 | } |
| 125 | |
| 126 | fn analyze_statement( |
| 127 | &self, |
| 128 | statement: &Statement, |
| 129 | analysis: &mut SqlAnalysisResult, |
| 130 | depth: usize, |
| 131 | original_query: &str |
| 132 | ) -> Result<(), PgSqliteError> { |
| 133 | analysis.max_depth = analysis.max_depth.max(depth); |
| 134 | |
| 135 | match statement { |
| 136 | Statement::Query(query) => { |
| 137 | self.analyze_query_statement(query, analysis, depth + 1, original_query)?; |
| 138 | } |
| 139 | Statement::Insert { .. } | Statement::Update { .. } | Statement::Delete { .. } => { |
| 140 | analysis.has_modifying_statements = true; |
| 141 | self.analyze_dml_statement(statement, analysis, depth + 1, original_query)?; |
| 142 | } |
| 143 | Statement::Drop { .. } | Statement::CreateTable { .. } | Statement::AlterTable { .. } => { |
| 144 | analysis.has_ddl_statements = true; |
| 145 | // DDL statements in injection contexts are highly suspicious |
| 146 | if depth > 0 || analysis.statement_count > 0 { |
| 147 | events::sql_injection_attempt(None, None, original_query, "suspicious DDL"); |
| 148 | return Err(PgSqliteError::InvalidParameter( |
| 149 | "Suspicious DDL statement detected".to_string() |
| 150 | )); |
| 151 | } |
| 152 | } |
| 153 | _ => { |
| 154 | // Other statement types |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | analysis.statement_count += 1; |
| 159 | Ok(()) |
| 160 | } |
| 161 | |
| 162 | fn analyze_query_statement( |
| 163 | &self, |
no test coverage detected