Skip to content

Commit a38405e

Browse files
committed
fix formatting error/warnings
1 parent 748e96d commit a38405e

1 file changed

Lines changed: 24 additions & 30 deletions

File tree

python/ql/src/experimental/Security/CWE-409/DecompressionBombs.ql

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import semmle.python.ApiGraphs
1818
import semmle.python.dataflow.new.RemoteFlowSources
1919
import semmle.python.dataflow.new.internal.DataFlowPublic
2020

21-
module pyZipFile {
21+
module PyZipFile {
2222
/**
2323
* ```python
2424
* zipfile.PyZipFile()
@@ -78,7 +78,7 @@ module pyZipFile {
7878

7979
/**
8080
* Same as ZipFile
81-
* I made PyZipFile seperated from ZipFile as in future this will be compatible
81+
* I made PyZipFile separated from ZipFile as in future this will be compatible
8282
* if anyone want to add new methods an sink to each object.
8383
*/
8484
predicate isAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
@@ -283,7 +283,7 @@ module ZipFile {
283283
}
284284

285285
/**
286-
* a sanitizers which check if there is a managed read
286+
* a sanitizers which check if there is a managed read
287287
* ```python
288288
* with zipfile.ZipFile(zipFileName) as myzip:
289289
* with myzip.open(fileinfo.filename, mode="r") as myfile:
@@ -394,13 +394,11 @@ module TarFile {
394394
module Shutil {
395395
DataFlow::Node isSink() {
396396
result =
397-
[
398-
API::moduleImport("shutil")
399-
.getMember("unpack_archive")
400-
.getACall()
401-
.getParameter(0, "filename")
402-
.asSink()
403-
]
397+
API::moduleImport("shutil")
398+
.getMember("unpack_archive")
399+
.getACall()
400+
.getParameter(0, "filename")
401+
.asSink()
404402
}
405403
}
406404

@@ -445,8 +443,8 @@ module Pandas {
445443
module FileAndFormRemoteFlowSource {
446444
class FastAPI extends DataFlow::Node {
447445
FastAPI() {
448-
exists(API::Node fastAPIParam |
449-
fastAPIParam =
446+
exists(API::Node fastApiParam |
447+
fastApiParam =
450448
API::moduleImport("fastapi")
451449
.getMember("FastAPI")
452450
.getReturn()
@@ -459,11 +457,11 @@ module FileAndFormRemoteFlowSource {
459457
.getASubclass*()
460458
.getAValueReachableFromSource()
461459
.asExpr() =
462-
fastAPIParam.asSource().asExpr().(Parameter).getAnnotation().getASubExpression*()
460+
fastApiParam.asSource().asExpr().(Parameter).getAnnotation().getASubExpression*()
463461
|
464462
// in the case of List of files
465463
exists(For f, Attribute attr, DataFlow::Node a, DataFlow::Node b |
466-
fastAPIParam.getAValueReachableFromSource().asExpr() = f.getIter().getASubExpression*()
464+
fastApiParam.getAValueReachableFromSource().asExpr() = f.getIter().getASubExpression*()
467465
|
468466
// file.file in following
469467
// def upload(files: List[UploadFile] = File(...)):
@@ -477,20 +475,18 @@ module FileAndFormRemoteFlowSource {
477475
this.asExpr() = attr
478476
)
479477
or
480-
// exclude cases like type-annotated with `Response`
481-
// and not not any(Response::RequestHandlerParam src).asExpr() = result
482478
this =
483479
[
484-
fastAPIParam.asSource(),
485-
fastAPIParam.getMember(["filename", "content_type", "headers", "file"]).asSource(),
486-
fastAPIParam.getMember(["read"]).getReturn().asSource(),
480+
fastApiParam.asSource(),
481+
fastApiParam.getMember(["filename", "content_type", "headers", "file"]).asSource(),
482+
fastApiParam.getMember("read").getReturn().asSource(),
487483
// file-like object, I'm trying to not do additional work here by using already existing file-like objs if it is possible
488-
// fastAPIParam.getMember("file").getAMember().asSource(),
484+
// fastApiParam.getMember("file").getAMember().asSource(),
489485
]
490486
)
491487
or
492-
exists(API::Node fastAPIParam |
493-
fastAPIParam =
488+
exists(API::Node fastApiParam |
489+
fastApiParam =
494490
API::moduleImport("fastapi")
495491
.getMember("FastAPI")
496492
.getReturn()
@@ -503,11 +499,11 @@ module FileAndFormRemoteFlowSource {
503499
.getASubclass*()
504500
.getAValueReachableFromSource()
505501
.asExpr() =
506-
fastAPIParam.asSource().asExpr().(Parameter).getAnnotation().getASubExpression*()
502+
fastApiParam.asSource().asExpr().(Parameter).getAnnotation().getASubExpression*()
507503
|
508504
// in the case of List of files
509505
exists(For f, Attribute attr, DataFlow::Node a, DataFlow::Node b |
510-
fastAPIParam.getAValueReachableFromSource().asExpr() = f.getIter().getASubExpression*()
506+
fastApiParam.getAValueReachableFromSource().asExpr() = f.getIter().getASubExpression*()
511507
|
512508
// file.file in following
513509
// def upload(files: List[UploadFile] = File(...)):
@@ -521,9 +517,7 @@ module FileAndFormRemoteFlowSource {
521517
this.asExpr() = attr
522518
)
523519
or
524-
// exclude cases like type-annotated with `Response`
525-
// and not not any(Response::RequestHandlerParam src).asExpr() = result
526-
this = fastAPIParam.asSource()
520+
this = fastApiParam.asSource()
527521
) and
528522
exists(this.getLocation().getFile().getRelativePath())
529523
}
@@ -575,8 +569,8 @@ module BombsConfig implements DataFlow::ConfigSig {
575569
predicate isSink(DataFlow::Node sink) {
576570
sink =
577571
[
578-
pyZipFile::isSink(), ZipFile::isSink(), Gzip::isSink(), Lzma::isSink(), Bz2::isSink(),
579-
TarFile::isSink(), Lzma::isSink(), Shutil::isSink(), Pandas::isSink()
572+
PyZipFile::isSink(), ZipFile::isSink(), Gzip::isSink(), Lzma::isSink(), Bz2::isSink(),
573+
TarFile::isSink(), Shutil::isSink(), Pandas::isSink()
580574
] and
581575
exists(sink.getLocation().getFile().getRelativePath())
582576
}
@@ -585,7 +579,7 @@ module BombsConfig implements DataFlow::ConfigSig {
585579
(
586580
isAdditionalTaintStepTextIOWrapper(nodeFrom, nodeTo) or
587581
ZipFile::isAdditionalTaintStep(nodeFrom, nodeTo) or
588-
pyZipFile::isAdditionalTaintStep(nodeFrom, nodeTo) or
582+
PyZipFile::isAdditionalTaintStep(nodeFrom, nodeTo) or
589583
TarFile::isAdditionalTaintStep(nodeFrom, nodeTo)
590584
) and
591585
exists(nodeTo.getLocation().getFile().getRelativePath())

0 commit comments

Comments
 (0)