-
Hi, I have the following simple case I cannot implement using QL syntax, please.
Can I combine two TaintTracking configurations? I mean something like import semmle.python.dataflow.new.TaintTracking
class Config1 extends TaintTracking::Configuration
override predicate isSource(DataFlow::Node source) { source instanceof source1 }
override predicate isSink(DataFlow::Node sink) { sink instanceof sink1 }
}
class Config2 extends TaintTracking::Configuration
override predicate isSource(DataFlow::Node source) { exists(config1 cfg, DataFlow::Node src | cfg.hasFlow(src, source)) }
override predicate isSink(DataFlow::Node sink) { sink instanceof sink2 }
}
from Config2 config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink)
select sink, source, sink, "Str" But the problem with such implementation is Please, how do you suggest that I proceed ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
The idea of using |
Beta Was this translation helpful? Give feedback.
-
It's not possible to extend import semmle.python.dataflow.new.TaintTracking
import semmle.python.dataflow.new.TaintTracking2
class Config1 extends TaintTracking::Configuration
override predicate isSource(DataFlow::Node source) { source instanceof Source1 }
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink1 }
}
class Config2 extends TaintTracking2::Configuration
override predicate isSource(DataFlow::Node source) { any(Config1 cfg).hasFlow(_, source) }
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink2 }
}
from Config2 config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink)
select sink, source, sink, "Str" Alternatively, your class State1 extends DataFlow::FlowState {
State1() { this = "State1" }
}
class State2 extends DataFlow::FlowState {
State2() { this = "State2" }
}
class Config extends TaintTracking::Configuration
override predicate isSource(DataFlow::Node source, DataFlow::FlowState state) {
source instanceof Source1 and
state instanceof State1
}
override predicate isSink(DataFlow::Node sink, DataFlow::FlowState state) {
sink instanceof Sink2 and
state instanceof State2
}
override predicate isAdditionalTaintStep(
DataFlow::Node node1, DataFlow::FlowState state1, DataFlow::Node node2, DataFlow::FlowState state2
) {
node1 instanceof Sink1 and
state1 instanceof State1 and
node2 instanceof Source2 and
state2 instanceof State2 and
}
} |
Beta Was this translation helpful? Give feedback.
It's not possible to extend
TaintTracking::Configuration
twice in the same query. If you need two configurations then you'll need to importTaintTracking2
and useTaintTracking2::Configuration
: