Skip to content

Commit efa59fd

Browse files
committed
Rust: Make changes based on PR feedback
1 parent 44bebed commit efa59fd

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

rust/ql/lib/codeql/rust/dataflow/DataFlow.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@ module DataFlow {
1919

2020
final class PostUpdateNode = Node::PostUpdateNode;
2121

22-
predicate localFlowStep = DataFlowImpl::localFlowStep/2;
22+
/**
23+
* Holds if data flows from `nodeFrom` to `nodeTo` in exactly one local
24+
* (intra-procedural) step.
25+
*/
26+
predicate localFlowStep = DataFlowImpl::localFlowStepImpl/2;
27+
28+
/**
29+
* Holds if data flows from `source` to `sink` in zero or more local
30+
* (intra-procedural) steps.
31+
*/
32+
pragma[inline]
33+
predicate localFlow(Node::Node source, Node::Node sink) { localFlowStep*(source, sink) }
2334

2435
import DataFlowMake<Location, DataFlowImpl::RustDataFlow>
2536
}

rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
private import codeql.util.Void
6+
private import codeql.util.Unit
67
private import codeql.dataflow.DataFlow
78
private import codeql.dataflow.internal.DataFlowImpl
89
private import rust
@@ -26,11 +27,6 @@ module Node {
2627
*/
2728
Expr asExpr() { none() }
2829

29-
/**
30-
* Gets this node's underlying pattern, if any.
31-
*/
32-
Pat asPattern() { none() }
33-
3430
/**
3531
* Gets the control flow node that corresponds to this data flow node.
3632
*/
@@ -73,7 +69,7 @@ module Node {
7369
final class ArgumentNode = NaNode;
7470

7571
final class ReturnNode extends NaNode {
76-
ReturnKind getKind() { none() }
72+
RustDataFlow::ReturnKind getKind() { none() }
7773
}
7874

7975
final class OutNode = NaNode;
@@ -152,7 +148,7 @@ module RustDataFlow implements InputSig<Location> {
152148

153149
OutNode getAnOutNode(DataFlowCall call, ReturnKind kind) { none() }
154150

155-
final class DataFlowType = Void;
151+
final class DataFlowType = Unit;
156152

157153
predicate compatibleTypes(DataFlowType t1, DataFlowType t2) { any() }
158154

@@ -281,21 +277,16 @@ module RustDataFlow implements InputSig<Location> {
281277
class DataFlowSecondLevelScope = Void;
282278
}
283279

284-
import RustDataFlow
285-
import MakeImpl<Location, RustDataFlow>
280+
final class ContentSet = RustDataFlow::ContentSet;
286281

287-
/**
288-
* Holds if data flows from `nodeFrom` to `nodeTo` in exactly one local
289-
* (intra-procedural) step.
290-
*/
291-
predicate localFlowStep = localFlowStepImpl/2;
282+
import MakeImpl<Location, RustDataFlow>
292283

293284
/** A collection of cached types and predicates to be evaluated in the same stage. */
294285
cached
295286
private module Cached {
296287
cached
297288
newtype TNode =
298-
TExprNode(CfgNode n, Expr e) or
289+
TExprNode(CfgNode n, Expr e) { n.getAstNode() = e } or
299290
TSourceParameterNode(Param param)
300291

301292
cached
@@ -311,14 +302,7 @@ private module Cached {
311302

312303
/** This is the local flow predicate that is exposed. */
313304
cached
314-
predicate localFlowStepImpl(Node nodeFrom, Node nodeTo) { none() }
305+
predicate localFlowStepImpl(Node::Node nodeFrom, Node::Node nodeTo) { none() }
315306
}
316307

317308
import Cached
318-
319-
/**
320-
* Holds if data flows from `source` to `sink` in zero or more local
321-
* (intra-procedural) steps.
322-
*/
323-
pragma[inline]
324-
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }

rust/ql/lib/codeql/rust/dataflow/internal/TaintTrackingImpl.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ private import codeql.dataflow.TaintTracking
33
private import DataFlowImpl
44

55
module RustTaintTracking implements InputSig<Location, RustDataFlow> {
6-
predicate defaultTaintSanitizer(Node node) { none() }
6+
predicate defaultTaintSanitizer(Node::Node node) { none() }
77

88
/**
99
* Holds if the additional step from `src` to `sink` should be included in all
1010
* global taint flow configurations.
1111
*/
12-
predicate defaultAdditionalTaintStep(Node src, Node sink, string model) { none() }
12+
predicate defaultAdditionalTaintStep(Node::Node src, Node::Node sink, string model) { none() }
1313

1414
/**
1515
* Holds if taint flow configurations should allow implicit reads of `c` at sinks
1616
* and inputs to additional taint steps.
1717
*/
1818
bindingset[node]
19-
predicate defaultImplicitTaintRead(Node node, ContentSet c) { none() }
19+
predicate defaultImplicitTaintRead(Node::Node node, ContentSet c) { none() }
2020
}

0 commit comments

Comments
 (0)