@@ -7,6 +7,8 @@ private import rust
77private import codeql.dataflow.DataFlow
88private import internal.DataFlowImpl as DataFlowImpl
99private import DataFlowImpl:: Node as Node
10+ private import codeql.rust.controlflow.ControlFlowGraph as Cfg
11+ private import codeql.rust.controlflow.CfgNodes as CfgNodes
1012
1113/**
1214 * Provides classes for performing local (intra-procedural) and global
@@ -15,6 +17,8 @@ private import DataFlowImpl::Node as Node
1517module DataFlow {
1618 final class Node = Node:: NodePublic ;
1719
20+ final class ExprNode = Node:: ExprNode ;
21+
1822 /**
1923 * The value of a parameter at function entry, viewed as a node in a data
2024 * flow graph.
@@ -41,4 +45,31 @@ module DataFlow {
4145 predicate localFlow ( Node:: Node source , Node:: Node sink ) { localFlowStep * ( source , sink ) }
4246
4347 import DataFlowMake< Location , DataFlowImpl:: RustDataFlow >
48+
49+ /**
50+ * Holds if the guard `g` validates the expression `e` upon evaluating to `v`.
51+ *
52+ * The expression `e` is expected to be a syntactic part of the guard `g`.
53+ * For example, the guard `g` might be a call `isSafe(x)` and the expression `e`
54+ * the argument `x`.
55+ */
56+ signature predicate guardChecksSig ( CfgNodes:: AstCfgNode g , Cfg:: CfgNode e , boolean branch ) ;
57+
58+ /**
59+ * Provides a set of barrier nodes for a guard that validates an expression.
60+ *
61+ * This is expected to be used in `isBarrier`/`isSanitizer` definitions
62+ * in data flow and taint tracking.
63+ */
64+ module BarrierGuard< guardChecksSig / 3 guardChecks> {
65+ private import internal.DataFlowImpl:: SsaFlow as SsaFlow
66+ private import internal.SsaImpl as SsaImpl
67+
68+ /** Gets a node that is safely guarded by the given guard check. */
69+ pragma [ nomagic]
70+ Node getABarrierNode ( ) {
71+ SsaFlow:: asNode ( result ) =
72+ SsaImpl:: DataFlowIntegration:: BarrierGuard< guardChecks / 3 > :: getABarrierNode ( )
73+ }
74+ }
4475}
0 commit comments