simplify TableAccess::run

This commit is contained in:
Kevin Zimmerman
2023-07-25 19:34:37 -05:00
parent 1c26aa3547
commit 33724ea670

View File

@@ -30,21 +30,18 @@ impl<'a> Plugin for TableAccess<'a> {
return Ok(PluginOutput::Allow); return Ok(PluginOutput::Allow);
} }
let mut found = None; let control_flow = visit_relations(ast, |relation| {
visit_relations(ast, |relation| {
let relation = relation.to_string(); let relation = relation.to_string();
let table_name = relation.split('.').last().unwrap().to_string(); let table_name = relation.split('.').last().unwrap().to_string();
if self.tables.contains(&table_name) { if self.tables.contains(&table_name) {
found = Some(table_name); ControlFlow::Break(table_name)
ControlFlow::<()>::Break(())
} else { } else {
ControlFlow::<()>::Continue(()) ControlFlow::Continue(())
} }
}); });
if let Some(found) = found { if let ControlFlow::Break(found) = control_flow {
debug!("Blocking access to table \"{found}\""); debug!("Blocking access to table \"{found}\"");
Ok(PluginOutput::Deny(format!( Ok(PluginOutput::Deny(format!(