@@ -8,6 +8,8 @@ private import codeql.dataflow.DataFlow
88private import internal.DataFlowImpl as DataFlowImpl
99private import internal.Node as Node
1010private import internal.Content as Content
11+ private import codeql.rust.controlflow.ControlFlowGraph as Cfg
12+ private import codeql.rust.controlflow.CfgNodes as CfgNodes
1113
1214/**
1315 * Provides classes for performing local (intra-procedural) and global
@@ -16,6 +18,8 @@ private import internal.Content as Content
1618module DataFlow {
1719 final class Node = Node:: NodePublic ;
1820
21+ final class ExprNode = Node:: ExprNode ;
22+
1923 /**
2024 * The value of a parameter at function entry, viewed as a node in a data
2125 * flow graph.
@@ -56,4 +60,31 @@ module DataFlow {
5660 predicate localFlow ( Node:: Node source , Node:: Node sink ) { localFlowStep * ( source , sink ) }
5761
5862 import DataFlowMake< Location , DataFlowImpl:: RustDataFlow >
63+
64+ /**
65+ * Holds if the guard `g` validates the expression `e` upon evaluating to `v`.
66+ *
67+ * The expression `e` is expected to be a syntactic part of the guard `g`.
68+ * For example, the guard `g` might be a call `isSafe(x)` and the expression `e`
69+ * the argument `x`.
70+ */
71+ signature predicate guardChecksSig ( CfgNodes:: AstCfgNode g , Cfg:: CfgNode e , boolean branch ) ;
72+
73+ /**
74+ * Provides a set of barrier nodes for a guard that validates an expression.
75+ *
76+ * This is expected to be used in `isBarrier`/`isSanitizer` definitions
77+ * in data flow and taint tracking.
78+ */
79+ module BarrierGuard< guardChecksSig / 3 guardChecks> {
80+ private import internal.DataFlowImpl:: SsaFlow as SsaFlow
81+ private import internal.SsaImpl as SsaImpl
82+
83+ /** Gets a node that is safely guarded by the given guard check. */
84+ pragma [ nomagic]
85+ Node getABarrierNode ( ) {
86+ SsaFlow:: asNode ( result ) =
87+ SsaImpl:: DataFlowIntegration:: BarrierGuard< guardChecks / 3 > :: getABarrierNode ( )
88+ }
89+ }
5990}
0 commit comments