@@ -8,6 +8,8 @@ private import codeql.dataflow.DataFlow
8
8
private import internal.DataFlowImpl as DataFlowImpl
9
9
private import internal.Node as Node
10
10
private import internal.Content as Content
11
+ private import codeql.rust.controlflow.ControlFlowGraph as Cfg
12
+ private import codeql.rust.controlflow.CfgNodes as CfgNodes
11
13
12
14
/**
13
15
* Provides classes for performing local (intra-procedural) and global
@@ -16,6 +18,8 @@ private import internal.Content as Content
16
18
module DataFlow {
17
19
final class Node = Node:: NodePublic ;
18
20
21
+ final class ExprNode = Node:: ExprNode ;
22
+
19
23
/**
20
24
* The value of a parameter at function entry, viewed as a node in a data
21
25
* flow graph.
@@ -56,4 +60,31 @@ module DataFlow {
56
60
predicate localFlow ( Node:: Node source , Node:: Node sink ) { localFlowStep * ( source , sink ) }
57
61
58
62
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
+ }
59
90
}
0 commit comments