mirror of
https://github.com/github/codeql.git
synced 2026-02-23 18:33:42 +01:00
Fixes the test failures that arose from making `ExtractedArgumentNode` local. For the consistency checks, we now explicitly exclude the `ExtractedArgumentNode`s (now much more plentiful due to the overapproximation) that don't have a corresponding `getCallArg` tuple. For various queries/tests using `instanceof ArgumentNode`, we instead us `isArgumentNode`, which explicitly filters out the ones for which `isArgumentOf` doesn't hold (which, again, is the case for most of the nodes in the overapproximation).
45 lines
1.5 KiB
Plaintext
45 lines
1.5 KiB
Plaintext
import python
|
|
import semmle.python.dataflow.new.DataFlow
|
|
private import semmle.python.dataflow.new.internal.DataFlowPrivate
|
|
import FlowTest
|
|
|
|
module MaximalFlowTest implements FlowTestSig {
|
|
string flowTag() { result = "flow" }
|
|
|
|
predicate relevantFlow(DataFlow::Node source, DataFlow::Node sink) {
|
|
source != sink and
|
|
MaximalFlows::flow(source, sink) and
|
|
// exclude ModuleVariableNodes (which have location 0:0:0:0)
|
|
not sink instanceof DataFlow::ModuleVariableNode
|
|
}
|
|
}
|
|
|
|
import MakeTest<MakeTestSig<MaximalFlowTest>>
|
|
|
|
/**
|
|
* A configuration to find all "maximal" flows.
|
|
* To be used on small programs.
|
|
*/
|
|
module MaximalFlowsConfig implements DataFlow::ConfigSig {
|
|
predicate isSource(DataFlow::Node node) {
|
|
exists(node.getLocation().getFile().getRelativePath()) and
|
|
not node.asCfgNode() instanceof CallNode and
|
|
not node.asCfgNode().getNode() instanceof Return and
|
|
not node instanceof DataFlow::ParameterNode and
|
|
not node instanceof DataFlow::PostUpdateNode and
|
|
// not node.asExpr() instanceof FunctionExpr and
|
|
// not node.asExpr() instanceof ClassExpr and
|
|
not DataFlow::localFlowStep(_, node)
|
|
}
|
|
|
|
predicate isSink(DataFlow::Node node) {
|
|
exists(node.getLocation().getFile().getRelativePath()) and
|
|
not any(CallNode c).getArg(_) = node.asCfgNode() and
|
|
not isArgumentNode(node, _, _) and
|
|
not node.asCfgNode().(NameNode).getId().matches("SINK%") and
|
|
not DataFlow::localFlowStep(node, _)
|
|
}
|
|
}
|
|
|
|
module MaximalFlows = DataFlow::Global<MaximalFlowsConfig>;
|