Skip to content

Commit 9502756

Browse files
committed
Python: Autoformat dataflow files
1 parent 816a8d1 commit 9502756

File tree

9 files changed

+508
-532
lines changed

9 files changed

+508
-532
lines changed

python/ql/src/semmle/python/dataflow/Configuration.qll

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ private import semmle.python.objects.ObjectInternal
44
private import semmle.python.dataflow.Implementation
55

66
module TaintTracking {
7-
87
class Source = TaintSource;
98

109
class Sink = TaintSink;
@@ -16,13 +15,11 @@ module TaintTracking {
1615
class PathSink = TaintTrackingNode;
1716

1817
abstract class Configuration extends string {
19-
2018
/* Required to prevent compiler warning */
2119
bindingset[this]
2220
Configuration() { this = this }
2321

2422
/* Old implementation API */
25-
2623
predicate isSource(Source src) { none() }
2724

2825
predicate isSink(Sink sink) { none() }
@@ -32,7 +29,6 @@ module TaintTracking {
3229
predicate isExtension(Extension extension) { none() }
3330

3431
/* New implementation API */
35-
3632
/**
3733
* Holds if `src` is a source of taint of `kind` that is relevant
3834
* for this configuration.
@@ -66,7 +62,9 @@ module TaintTracking {
6662
/**
6763
* Holds if `src -> dest` is a flow edge converting taint from `srckind` to `destkind`.
6864
*/
69-
predicate isAdditionalFlowStep(DataFlow::Node src, DataFlow::Node dest, TaintKind srckind, TaintKind destkind) {
65+
predicate isAdditionalFlowStep(
66+
DataFlow::Node src, DataFlow::Node dest, TaintKind srckind, TaintKind destkind
67+
) {
7068
none()
7169
}
7270

@@ -79,9 +77,7 @@ module TaintTracking {
7977
* Holds if `node` should be considered as a barrier to flow of `kind`.
8078
*/
8179
predicate isBarrier(DataFlow::Node node, TaintKind kind) {
82-
exists(Sanitizer sanitizer |
83-
this.isSanitizer(sanitizer)
84-
|
80+
exists(Sanitizer sanitizer | this.isSanitizer(sanitizer) |
8581
sanitizer.sanitizingNode(kind, node.asCfgNode())
8682
or
8783
sanitizer.sanitizingEdge(kind, node.asVariable())
@@ -112,16 +108,18 @@ module TaintTracking {
112108
* Holds if flow from `src` to `dest` is prohibited when the incoming taint is `srckind` and the outgoing taint is `destkind`.
113109
* Note that `srckind` and `destkind` can be the same.
114110
*/
115-
predicate isBarrierEdge(DataFlow::Node src, DataFlow::Node dest, TaintKind srckind, TaintKind destkind) { none() }
111+
predicate isBarrierEdge(
112+
DataFlow::Node src, DataFlow::Node dest, TaintKind srckind, TaintKind destkind
113+
) {
114+
none()
115+
}
116116

117117
/* Common query API */
118-
119118
predicate hasFlowPath(PathSource src, PathSink sink) {
120119
this.(TaintTrackingImplementation).hasFlowPath(src, sink)
121120
}
122121

123122
/* Old query API */
124-
125123
/* deprecated */
126124
deprecated predicate hasFlow(Source src, Sink sink) {
127125
exists(PathSource psrc, PathSink psink |
@@ -132,15 +130,12 @@ module TaintTracking {
132130
}
133131

134132
/* New query API */
135-
136133
predicate hasSimpleFlow(DataFlow::Node src, DataFlow::Node sink) {
137134
exists(PathSource psrc, PathSink psink |
138135
this.hasFlowPath(psrc, psink) and
139136
src = psrc.getNode() and
140137
sink = psink.getNode()
141138
)
142139
}
143-
144140
}
145-
146141
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import semmle.python.security.TaintTracking
1+
import semmle.python.security.TaintTracking

python/ql/src/semmle/python/dataflow/Files.qll

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,18 @@ import python
22
import semmle.python.security.TaintTracking
33

44
class OpenFile extends TaintKind {
5-
65
OpenFile() { this = "file.open" }
76

87
override string repr() { result = "an open file" }
9-
10-
118
}
129

1310
class OpenFileConfiguration extends TaintTracking::Configuration {
14-
15-
OpenFileConfiguration() { this = "Open file configuration" }
11+
OpenFileConfiguration() { this = "Open file configuration" }
1612

1713
override predicate isSource(DataFlow::Node src, TaintKind kind) {
1814
theOpenFunction().(FunctionObject).getACall() = src.asCfgNode() and
1915
kind instanceof OpenFile
2016
}
2117

22-
override predicate isSink(DataFlow::Node sink, TaintKind kind) {
23-
none()
24-
}
25-
18+
override predicate isSink(DataFlow::Node sink, TaintKind kind) { none() }
2619
}

0 commit comments

Comments
 (0)