mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: Update rest of tests to new dataflow lib
I had missed these originally, since I had just fixed the ones that were highlighted in the actions logs, thinking they had covered everything :(
This commit is contained in:
@@ -10,26 +10,18 @@ predicate pointsToOrigin(DataFlow::CfgNode pointer, DataFlow::CfgNode origin) {
|
||||
origin.getNode() = pointer.getNode().pointsTo().getOrigin()
|
||||
}
|
||||
|
||||
class PointsToConfiguration extends DataFlow::Configuration {
|
||||
PointsToConfiguration() { this = "PointsToConfiguration" }
|
||||
module PointsToConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node node) { pointsToOrigin(_, node) }
|
||||
|
||||
override predicate isSource(DataFlow::Node node) { pointsToOrigin(_, node) }
|
||||
|
||||
override predicate isSink(DataFlow::Node node) { pointsToOrigin(node, _) }
|
||||
predicate isSink(DataFlow::Node node) { pointsToOrigin(node, _) }
|
||||
}
|
||||
|
||||
predicate hasFlow(DataFlow::Node origin, DataFlow::Node pointer) {
|
||||
exists(PointsToConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink |
|
||||
source.getNode() = origin and
|
||||
sink.getNode() = pointer and
|
||||
config.hasFlowPath(source, sink)
|
||||
)
|
||||
}
|
||||
module PointsToFlow = DataFlow::Global<PointsToConfig>;
|
||||
|
||||
from DataFlow::Node pointer, DataFlow::Node origin
|
||||
where
|
||||
exists(pointer.getLocation().getFile().getRelativePath()) and
|
||||
exists(origin.getLocation().getFile().getRelativePath()) and
|
||||
pointsToOrigin(pointer, origin) and
|
||||
not hasFlow(origin, pointer)
|
||||
not PointsToFlow::flow(origin, pointer)
|
||||
select origin, pointer
|
||||
|
||||
@@ -5,20 +5,18 @@ import semmle.python.dataflow.new.TaintTracking
|
||||
import semmle.python.dataflow.new.DataFlow
|
||||
private import semmle.python.ApiGraphs
|
||||
|
||||
class BasicTaintTracking extends TaintTracking::Configuration {
|
||||
BasicTaintTracking() { this = "BasicTaintTracking" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
module BasicTaintTrackingConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source = ModelOutput::getASourceNode("test-source").asSource()
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
sink = ModelOutput::getASinkNode("test-sink").asSink()
|
||||
}
|
||||
predicate isSink(DataFlow::Node sink) { sink = ModelOutput::getASinkNode("test-sink").asSink() }
|
||||
}
|
||||
|
||||
module TestTaintTrackingFlow = TaintTracking::Global<BasicTaintTrackingConfig>;
|
||||
|
||||
query predicate taintFlow(DataFlow::Node source, DataFlow::Node sink) {
|
||||
any(BasicTaintTracking tr).hasFlow(source, sink)
|
||||
TestTaintTrackingFlow::flow(source, sink)
|
||||
}
|
||||
|
||||
query predicate isSink(DataFlow::Node node, string kind) {
|
||||
|
||||
Reference in New Issue
Block a user