(
&self,
table: &TableFactor,
analysis: &mut SqlAnalysisResult,
depth: usize,
original_query: &str
)
| 258 | } |
| 259 | |
| 260 | fn analyze_table_factor( |
| 261 | &self, |
| 262 | table: &TableFactor, |
| 263 | analysis: &mut SqlAnalysisResult, |
| 264 | depth: usize, |
| 265 | original_query: &str |
| 266 | ) -> Result<(), PgSqliteError> { |
| 267 | match table { |
| 268 | TableFactor::Table { name, .. } => { |
| 269 | let table_name = name.to_string().to_lowercase(); |
| 270 | |
| 271 | // Check for system/sensitive tables |
| 272 | if self.is_sensitive_table(&table_name) { |
| 273 | analysis.accesses_sensitive_tables = true; |
| 274 | |
| 275 | // System table access in complex queries is suspicious |
| 276 | if depth > 1 || analysis.union_count > 0 { |
| 277 | events::sql_injection_attempt(None, None, original_query, "suspicious system table access"); |
| 278 | return Err(PgSqliteError::InvalidParameter( |
| 279 | "Suspicious system table access detected".to_string() |
| 280 | )); |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | TableFactor::Derived { subquery, .. } => { |
| 285 | self.analyze_query_statement(subquery, analysis, depth + 1, original_query)?; |
| 286 | } |
| 287 | _ => {} |
| 288 | } |
| 289 | Ok(()) |
| 290 | } |
| 291 | |
| 292 | fn analyze_join( |
| 293 | &self, |
no test coverage detected