pub trait NodeQueries<'a>: IntoIterGlobalNodeswhere
Self::Iter: 'a,{
// Provided methods
fn siblings(self, ctx: &RootContext) -> NodeCluster { ... }
fn flows_to(
self,
sink: impl IntoIterGlobalNodes,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> bool { ... }
fn flows_to_all(
self,
sink: impl IntoIterGlobalNodes,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> Option<NodeCluster> { ... }
fn find_flow(
self,
sink: impl IntoIterGlobalNodes,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> Option<(GlobalNode, GlobalNode)> { ... }
fn consuming_call_sites(
self,
ctx: &'a RootContext,
) -> Box<dyn Iterator<Item = CallString> + 'a> { ... }
fn has_ctrl_influence(
self,
target: impl IntoIterGlobalNodes,
ctx: &RootContext,
) -> bool { ... }
fn find_ctrl_influence(
self,
target: impl IntoIterGlobalNodes,
ctx: &RootContext,
) -> Option<(GlobalNode, GlobalNode)> { ... }
fn has_ctrl_influence_all(
self,
target: impl IntoIterGlobalNodes,
ctx: &RootContext,
) -> Option<NodeCluster> { ... }
fn influencers(
self,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> Vec<GlobalNode> { ... }
fn influencees(
self,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> Vec<GlobalNode> { ... }
}
Expand description
Context queries conveniently accessible on nodes
Provided Methods§
Sourcefn siblings(self, ctx: &RootContext) -> NodeCluster
fn siblings(self, ctx: &RootContext) -> NodeCluster
Get other nodes at the same instruction
Sourcefn flows_to(
self,
sink: impl IntoIterGlobalNodes,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> bool
fn flows_to( self, sink: impl IntoIterGlobalNodes, ctx: &RootContext, edge_type: EdgeSelection, ) -> bool
Returns whether a node flows to a node through the configured edge type.
Nodes do not flow to themselves. CallArgument nodes do flow to their respective CallSites.
If you use flows_to with EdgeSelection::Control
, you might want to
consider using RootContext::has_ctrl_influence
, which additionally
considers intermediate nodes which the src node has data flow to and has
ctrl influence on the sink.
Sourcefn flows_to_all(
self,
sink: impl IntoIterGlobalNodes,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> Option<NodeCluster>
fn flows_to_all( self, sink: impl IntoIterGlobalNodes, ctx: &RootContext, edge_type: EdgeSelection, ) -> Option<NodeCluster>
An optimized version of the following pattern that performs only one
graph traversal instead of sink.len()
traversals:
for n in sink {
if !self.flows_to(n, ctx, edge_type) {
return /* violation */;
}
}
return /* success */;
Returns the that are not reachable from self
through the given edge
type. If all nodes have been reached the traversal short-circuits.
Sourcefn find_flow(
self,
sink: impl IntoIterGlobalNodes,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> Option<(GlobalNode, GlobalNode)>
fn find_flow( self, sink: impl IntoIterGlobalNodes, ctx: &RootContext, edge_type: EdgeSelection, ) -> Option<(GlobalNode, GlobalNode)>
Returns the sink node that is reached
Nodes do not flow to themselves. CallArgument nodes do flow to their respective CallSites.
If you use flows_to with EdgeSelection::Control
, you might want to consider using RootContext::has_ctrl_influence
, which additionally considers intermediate nodes which the src node has data flow to and has ctrl influence on the sink.
Sourcefn consuming_call_sites(
self,
ctx: &'a RootContext,
) -> Box<dyn Iterator<Item = CallString> + 'a>
fn consuming_call_sites( self, ctx: &'a RootContext, ) -> Box<dyn Iterator<Item = CallString> + 'a>
Call sites that consume this node directly. E.g. the outgoing edges.
Sourcefn has_ctrl_influence(
self,
target: impl IntoIterGlobalNodes,
ctx: &RootContext,
) -> bool
fn has_ctrl_influence( self, target: impl IntoIterGlobalNodes, ctx: &RootContext, ) -> bool
Returns whether there is direct control flow influence from influencer to sink, or there is some node which is data-flow influenced by influencer
and has direct control flow influence on target
. Or as expressed in code:
some n where self.flows_to(influencer, n, EdgeSelection::Data) && self.flows_to(n, target, EdgeSelection::Control)
.
Sourcefn find_ctrl_influence(
self,
target: impl IntoIterGlobalNodes,
ctx: &RootContext,
) -> Option<(GlobalNode, GlobalNode)>
fn find_ctrl_influence( self, target: impl IntoIterGlobalNodes, ctx: &RootContext, ) -> Option<(GlobalNode, GlobalNode)>
Returns whether there is direct control flow influence from influencer to sink, or there is some node which is data-flow influenced by influencer
and has direct control flow influence on target
. Or as expressed in code:
some n where self.flows_to(influencer, n, EdgeSelection::Data) && self.flows_to(n, target, EdgeSelection::Control)
.
Sourcefn has_ctrl_influence_all(
self,
target: impl IntoIterGlobalNodes,
ctx: &RootContext,
) -> Option<NodeCluster>
fn has_ctrl_influence_all( self, target: impl IntoIterGlobalNodes, ctx: &RootContext, ) -> Option<NodeCluster>
Similar to Self::has_ctrl_influence
but checks that all nodes in
target
are reached from self
. Returns the nodes that weren’t reached.
Sourcefn influencers(
self,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> Vec<GlobalNode>
fn influencers( self, ctx: &RootContext, edge_type: EdgeSelection, ) -> Vec<GlobalNode>
Returns iterator over all Nodes that influence the given sink Node.
Does not return the input node. A CallSite sink will return all of the associated CallArgument nodes.
Sourcefn influencees(
self,
ctx: &RootContext,
edge_type: EdgeSelection,
) -> Vec<GlobalNode>
fn influencees( self, ctx: &RootContext, edge_type: EdgeSelection, ) -> Vec<GlobalNode>
Returns iterator over all Nodes that are influenced by the given src Node.
Does not return the input node. A CallArgument src will return the associated CallSite.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.