Rust: Make changes based on PR feedback

This commit is contained in:
Simon Friis Vindum
2024-10-30 16:00:19 +01:00
parent 44bebedae6
commit efa59fd2b6
3 changed files with 22 additions and 27 deletions

View File

@@ -19,7 +19,18 @@ module DataFlow {
final class PostUpdateNode = Node::PostUpdateNode;
predicate localFlowStep = DataFlowImpl::localFlowStep/2;
/**
* Holds if data flows from `nodeFrom` to `nodeTo` in exactly one local
* (intra-procedural) step.
*/
predicate localFlowStep = DataFlowImpl::localFlowStepImpl/2;
/**
* Holds if data flows from `source` to `sink` in zero or more local
* (intra-procedural) steps.
*/
pragma[inline]
predicate localFlow(Node::Node source, Node::Node sink) { localFlowStep*(source, sink) }
import DataFlowMake<Location, DataFlowImpl::RustDataFlow>
}

View File

@@ -3,6 +3,7 @@
*/
private import codeql.util.Void
private import codeql.util.Unit
private import codeql.dataflow.DataFlow
private import codeql.dataflow.internal.DataFlowImpl
private import rust
@@ -26,11 +27,6 @@ module Node {
*/
Expr asExpr() { none() }
/**
* Gets this node's underlying pattern, if any.
*/
Pat asPattern() { none() }
/**
* Gets the control flow node that corresponds to this data flow node.
*/
@@ -73,7 +69,7 @@ module Node {
final class ArgumentNode = NaNode;
final class ReturnNode extends NaNode {
ReturnKind getKind() { none() }
RustDataFlow::ReturnKind getKind() { none() }
}
final class OutNode = NaNode;
@@ -152,7 +148,7 @@ module RustDataFlow implements InputSig<Location> {
OutNode getAnOutNode(DataFlowCall call, ReturnKind kind) { none() }
final class DataFlowType = Void;
final class DataFlowType = Unit;
predicate compatibleTypes(DataFlowType t1, DataFlowType t2) { any() }
@@ -281,21 +277,16 @@ module RustDataFlow implements InputSig<Location> {
class DataFlowSecondLevelScope = Void;
}
import RustDataFlow
import MakeImpl<Location, RustDataFlow>
final class ContentSet = RustDataFlow::ContentSet;
/**
* Holds if data flows from `nodeFrom` to `nodeTo` in exactly one local
* (intra-procedural) step.
*/
predicate localFlowStep = localFlowStepImpl/2;
import MakeImpl<Location, RustDataFlow>
/** A collection of cached types and predicates to be evaluated in the same stage. */
cached
private module Cached {
cached
newtype TNode =
TExprNode(CfgNode n, Expr e) or
TExprNode(CfgNode n, Expr e) { n.getAstNode() = e } or
TSourceParameterNode(Param param)
cached
@@ -311,14 +302,7 @@ private module Cached {
/** This is the local flow predicate that is exposed. */
cached
predicate localFlowStepImpl(Node nodeFrom, Node nodeTo) { none() }
predicate localFlowStepImpl(Node::Node nodeFrom, Node::Node nodeTo) { none() }
}
import Cached
/**
* Holds if data flows from `source` to `sink` in zero or more local
* (intra-procedural) steps.
*/
pragma[inline]
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }

View File

@@ -3,18 +3,18 @@ private import codeql.dataflow.TaintTracking
private import DataFlowImpl
module RustTaintTracking implements InputSig<Location, RustDataFlow> {
predicate defaultTaintSanitizer(Node node) { none() }
predicate defaultTaintSanitizer(Node::Node node) { none() }
/**
* Holds if the additional step from `src` to `sink` should be included in all
* global taint flow configurations.
*/
predicate defaultAdditionalTaintStep(Node src, Node sink, string model) { none() }
predicate defaultAdditionalTaintStep(Node::Node src, Node::Node sink, string model) { none() }
/**
* Holds if taint flow configurations should allow implicit reads of `c` at sinks
* and inputs to additional taint steps.
*/
bindingset[node]
predicate defaultImplicitTaintRead(Node node, ContentSet c) { none() }
predicate defaultImplicitTaintRead(Node::Node node, ContentSet c) { none() }
}