Skip to content

Commit e66cce7

Browse files
committed
python: add qldoc and refactor
The logic of which steps an `AdditionalTaintStep` has defined is now pushed into the defitnion of `AdditionalTaintStep`.
1 parent 4378924 commit e66cce7

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/TaintTrackingPrivate.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ private module Cached {
2727
predicate defaultAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo, string model) {
2828
localAdditionalTaintStep(nodeFrom, nodeTo, model)
2929
or
30-
any(AdditionalTaintStep a).step(nodeFrom, nodeTo) and
31-
model = "AdditionalTaintStep"
32-
or
33-
any(AdditionalTaintStep a).step(nodeFrom, nodeTo, model)
30+
any(AdditionalTaintStep a).hasStep(nodeFrom, nodeTo, model)
3431
}
3532

3633
/**

python/ql/lib/semmle/python/dataflow/new/internal/TaintTrackingPublic.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,25 @@ class AdditionalTaintStep extends Unit {
4747
/**
4848
* Holds if the step from `nodeFrom` to `nodeTo` should be considered a taint
4949
* step for all configurations.
50+
*
51+
* Note that it is now possible to also specify provenance of the taint step
52+
* by overwriting `step/3`.
5053
*/
5154
predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { none() }
5255

56+
/**
57+
* Holds if the step from `nodeFrom` to `nodeTo` should be considered a taint
58+
* step with provenance `model` for all configurations.
59+
*/
5360
predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo, string model) { none() }
61+
62+
/**
63+
* Holds if this `AdditionalTaintStep` defines a step from `nodeFrom` to `nodeTo`
64+
* with provenance `model`.
65+
*/
66+
final predicate hasStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo, string model) {
67+
this.step(nodeFrom, nodeTo) and model = "AdditionalTaintStep"
68+
or
69+
this.step(nodeFrom, nodeTo, model)
70+
}
5471
}

0 commit comments

Comments
 (0)