Skip to content

Commit b484aee

Browse files
committed
Python: Autoformat everything
Of course, `StringLiteral` being much longer than `StrConst` meant a bunch of files changed formatting.
1 parent 1c68c98 commit b484aee

File tree

10 files changed

+56
-18
lines changed

10 files changed

+56
-18
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@ newtype TContent =
612612
key = any(Keyword kw).getArg()
613613
or
614614
// d["key"] = ...
615-
key = any(SubscriptNode sub | sub.isStore() | sub.getIndex().getNode().(StringLiteral).getText())
615+
key =
616+
any(SubscriptNode sub | sub.isStore() | sub.getIndex().getNode().(StringLiteral).getText())
616617
or
617618
// d.setdefault("key", ...)
618619
exists(CallNode call | call.getFunction().(AttrNode).getName() = "setdefault" |

python/ql/lib/semmle/python/frameworks/Stdlib.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,8 @@ module StdlibPrivate {
29082908
exists(string algorithmName | result.matchesName(algorithmName) |
29092909
this.getDigestArg().asSink() = hashlibMember(algorithmName).asSource()
29102910
or
2911-
this.getDigestArg().getAValueReachingSink().asExpr().(StringLiteral).getText() = algorithmName
2911+
this.getDigestArg().getAValueReachingSink().asExpr().(StringLiteral).getText() =
2912+
algorithmName
29122913
)
29132914
}
29142915

python/ql/lib/semmle/python/regexp/RegexTreeView.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ module Impl implements RegexTreeViewSig {
230230
index > 0 and
231231
exists(int previousOffset | previousOffset = this.getPartOffset(index - 1) |
232232
result =
233-
previousOffset + re.(StringLiteral).getImplicitlyConcatenatedPart(index - 1).getContentLength()
233+
previousOffset +
234+
re.(StringLiteral).getImplicitlyConcatenatedPart(index - 1).getContentLength()
234235
)
235236
}
236237

python/ql/lib/semmle/python/security/dataflow/ServerSideRequestForgeryCustomizations.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ module ServerSideRequestForgery {
8888
exists(BinaryExprNode add |
8989
add.getOp() instanceof Add and
9090
add.getRight() = this.asCfgNode() and
91-
not add.getLeft().getNode().(StringLiteral).getText().toLowerCase() in ["http://", "https://"]
91+
not add.getLeft().getNode().(StringLiteral).getText().toLowerCase() in [
92+
"http://", "https://"
93+
]
9294
)
9395
or
9496
// % formatting

python/ql/src/experimental/Security/CWE-287-ConstantSecretKey/WebAppConstantSecretKeySource.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class WebAppConstantSecretKeySource extends DataFlow::Node {
2525
API::moduleImport("os").getMember("environ").getMember("get").getACall()
2626
] and
2727
cn.getNumArgument() = 2 and
28-
DataFlow::localFlow(any(DataFlow::Node n | n.asExpr() instanceof StringLiteral), cn.getArg(1)) and
28+
DataFlow::localFlow(any(DataFlow::Node n | n.asExpr() instanceof StringLiteral),
29+
cn.getArg(1)) and
2930
this.asExpr() = cn.asExpr()
3031
)
3132
) and

python/ql/src/experimental/Security/CWE-770/UnicodeDoS.ql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ class UnicodeCompatibilityNormalize extends API::CallNode {
2525
UnicodeCompatibilityNormalize() {
2626
(
2727
this = API::moduleImport("unicodedata").getMember("normalize").getACall() and
28-
this.getParameter(0).getAValueReachingSink().asExpr().(StringLiteral).getText() in ["NFKC", "NFKD"]
28+
this.getParameter(0).getAValueReachingSink().asExpr().(StringLiteral).getText() in [
29+
"NFKC", "NFKD"
30+
]
2931
or
3032
this = API::moduleImport("pyunormalize").getMember("normalize").getACall() and
31-
this.getParameter(0).getAValueReachingSink().asExpr().(StringLiteral).getText() in ["NFKC", "NFKD"]
33+
this.getParameter(0).getAValueReachingSink().asExpr().(StringLiteral).getText() in [
34+
"NFKC", "NFKD"
35+
]
3236
) and
3337
argIdx = 1
3438
or
3539
(
3640
this = API::moduleImport("textnorm").getMember("normalize_unicode").getACall() and
37-
this.getParameter(1).getAValueReachingSink().asExpr().(StringLiteral).getText() in ["NFKC", "NFKD"]
41+
this.getParameter(1).getAValueReachingSink().asExpr().(StringLiteral).getText() in [
42+
"NFKC", "NFKD"
43+
]
3844
or
3945
this = API::moduleImport("unidecode").getMember("unidecode").getACall()
4046
or

python/ql/src/experimental/semmle/python/frameworks/Sendgrid.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,12 @@ private module Sendgrid {
122122
contentElement =
123123
this.getKeywordParameter("request_body").getSubscript("content").getASubscript()
124124
|
125-
contentElement.getSubscript("type").getAValueReachingSink().asExpr().(StringLiteral).getText() =
126-
["text/html", "text/x-amp-html"] and
125+
contentElement
126+
.getSubscript("type")
127+
.getAValueReachingSink()
128+
.asExpr()
129+
.(StringLiteral)
130+
.getText() = ["text/html", "text/x-amp-html"] and
127131
result = contentElement.getSubscript("value").getAValueReachingSink()
128132
)
129133
or

python/ql/src/experimental/semmle/python/libraries/SmtpLib.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module SmtpLib {
2323

2424
private DataFlow::CallCfgNode mimeText(string mimetype) {
2525
result = smtpMimeTextInstance().getACall() and
26-
[result.getArg(1), result.getArgByName("_subtype")].asExpr().(StringLiteral).getText() = mimetype
26+
[result.getArg(1), result.getArgByName("_subtype")].asExpr().(StringLiteral).getText() =
27+
mimetype
2728
}
2829

2930
/**

python/ql/src/experimental/semmle/python/security/DecompressionBomb.qll

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,12 @@ module Gzip {
260260
this = gzipCall.getParameter(0, "filename").asSink() and
261261
(
262262
not exists(
263-
gzipCall.getParameter(1, "mode").getAValueReachingSink().asExpr().(StringLiteral).getText()
263+
gzipCall
264+
.getParameter(1, "mode")
265+
.getAValueReachingSink()
266+
.asExpr()
267+
.(StringLiteral)
268+
.getText()
264269
) or
265270
gzipCall
266271
.getParameter(1, "mode")
@@ -297,7 +302,12 @@ module Bz2 {
297302
this = bz2Call.getParameter(0, "filename").asSink() and
298303
(
299304
not exists(
300-
bz2Call.getParameter(1, "mode").getAValueReachingSink().asExpr().(StringLiteral).getText()
305+
bz2Call
306+
.getParameter(1, "mode")
307+
.getAValueReachingSink()
308+
.asExpr()
309+
.(StringLiteral)
310+
.getText()
301311
) or
302312
bz2Call
303313
.getParameter(1, "mode")
@@ -334,7 +344,12 @@ module Lzma {
334344
this = lzmaCall.getParameter(0, "filename").asSink() and
335345
(
336346
not exists(
337-
lzmaCall.getParameter(1, "mode").getAValueReachingSink().asExpr().(StringLiteral).getText()
347+
lzmaCall
348+
.getParameter(1, "mode")
349+
.getAValueReachingSink()
350+
.asExpr()
351+
.(StringLiteral)
352+
.getText()
338353
) or
339354
lzmaCall
340355
.getParameter(1, "mode")

python/ql/src/experimental/semmle/python/security/TimingAttack.qll

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ abstract class ClientSuppliedSecret extends DataFlow::CallCfgNode { }
204204
private class FlaskClientSuppliedSecret extends ClientSuppliedSecret {
205205
FlaskClientSuppliedSecret() {
206206
this = Flask::request().getMember("headers").getMember(["get", "get_all", "getlist"]).getACall() and
207-
[this.getArg(0), this.getArgByName(["key", "name"])].asExpr().(StringLiteral).getText().toLowerCase() =
208-
sensitiveheaders()
207+
[this.getArg(0), this.getArgByName(["key", "name"])]
208+
.asExpr()
209+
.(StringLiteral)
210+
.getText()
211+
.toLowerCase() = sensitiveheaders()
209212
}
210213
}
211214

@@ -243,8 +246,11 @@ private class WerkzeugClientSuppliedSecret extends ClientSuppliedSecret {
243246
WerkzeugClientSuppliedSecret() {
244247
this =
245248
headers().getMember(["headers", "META"]).getMember(["get", "get_all", "getlist"]).getACall() and
246-
[this.getArg(0), this.getArgByName(["key", "name"])].asExpr().(StringLiteral).getText().toLowerCase() =
247-
sensitiveheaders()
249+
[this.getArg(0), this.getArgByName(["key", "name"])]
250+
.asExpr()
251+
.(StringLiteral)
252+
.getText()
253+
.toLowerCase() = sensitiveheaders()
248254
}
249255
}
250256

0 commit comments

Comments
 (0)