use tree_sitter::{Node, Tree};
#[derive(Debug, Clone)]
pub struct FlowPath<'t> {
pub source: Node<'t>,
pub sink: Node<'t>,
pub steps: Vec<Node<'t>>,
}
pub trait FlowAnalyzer: Send + Sync {
fn analyze<'t>(
&self,
tree: &'t Tree,
source: &str,
sources: &[Node<'t>],
sinks: &[Node<'t>],
sanitizers: &[Node<'t>],
) -> Vec<FlowPath<'t>>;
}
#[cfg(test)]
mod tests {
use super::*;
struct StubAnalyzer;
impl FlowAnalyzer for StubAnalyzer {
fn analyze<'t>(
&self,
_tree: &'t Tree,
_source: &str,
_sources: &[Node<'t>],
_sinks: &[Node<'t>],
_sanitizers: &[Node<'t>],
) -> Vec<FlowPath<'t>> {
vec![]
}
}
#[test]
fn flow_analyzer_can_be_implemented() {
use std::sync::Arc;
drop(Arc::new(StubAnalyzer) as Arc<dyn FlowAnalyzer>);
}
}