зеркало из https://github.com/github/codeql.git
Python: Fix QL alerts
This commit is contained in:
Родитель
eb1be08bce
Коммит
2a7b593285
|
@ -7,7 +7,7 @@ private import semmle.python.dataflow.new.DataFlow
|
||||||
private import semmle.python.Concepts
|
private import semmle.python.Concepts
|
||||||
private import semmle.python.ApiGraphs
|
private import semmle.python.ApiGraphs
|
||||||
|
|
||||||
module BSon {
|
private module BSon {
|
||||||
/**
|
/**
|
||||||
* ObjectId returns a string representing an id.
|
* ObjectId returns a string representing an id.
|
||||||
* If at any time ObjectId can't parse it's input (like when a tainted dict in passed in),
|
* If at any time ObjectId can't parse it's input (like when a tainted dict in passed in),
|
||||||
|
|
|
@ -144,7 +144,7 @@ private module PyMongo {
|
||||||
private class MongoMapReduceQuery extends API::CallNode, NoSqlExecution::Range {
|
private class MongoMapReduceQuery extends API::CallNode, NoSqlExecution::Range {
|
||||||
MongoMapReduceQuery() { this = mongoCollection().getMember("map_reduce").getACall() }
|
MongoMapReduceQuery() { this = mongoCollection().getMember("map_reduce").getACall() }
|
||||||
|
|
||||||
override DataFlow::Node getQuery() { result in [this.getArgByName("query")] }
|
override DataFlow::Node getQuery() { result = this.getArgByName("query") }
|
||||||
|
|
||||||
override predicate interpretsDict() { any() }
|
override predicate interpretsDict() { any() }
|
||||||
|
|
||||||
|
@ -178,10 +178,10 @@ private module PyMongo {
|
||||||
* See https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#mongodb-expression-exp.-function
|
* See https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#mongodb-expression-exp.-function
|
||||||
*/
|
*/
|
||||||
private class FunctionQueryOperator extends DataFlow::Node, Decoding::Range {
|
private class FunctionQueryOperator extends DataFlow::Node, Decoding::Range {
|
||||||
API::Node dictionary;
|
|
||||||
DataFlow::Node query;
|
DataFlow::Node query;
|
||||||
|
|
||||||
FunctionQueryOperator() {
|
FunctionQueryOperator() {
|
||||||
|
exists(API::Node dictionary |
|
||||||
dictionary =
|
dictionary =
|
||||||
mongoCollection()
|
mongoCollection()
|
||||||
.getMember(mongoCollectionMethodName())
|
.getMember(mongoCollectionMethodName())
|
||||||
|
@ -191,6 +191,7 @@ private module PyMongo {
|
||||||
.getSubscript("$function") and
|
.getSubscript("$function") and
|
||||||
query = dictionary.getSubscript("body").asSink() and
|
query = dictionary.getSubscript("body").asSink() and
|
||||||
this = dictionary.asSink()
|
this = dictionary.asSink()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override DataFlow::Node getAnInput() { result = query }
|
override DataFlow::Node getAnInput() { result = query }
|
||||||
|
@ -208,10 +209,10 @@ private module PyMongo {
|
||||||
* See https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#mongodb-group-grp.-accumulator
|
* See https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#mongodb-group-grp.-accumulator
|
||||||
*/
|
*/
|
||||||
private class AccumulatorQueryOperator extends DataFlow::Node, Decoding::Range {
|
private class AccumulatorQueryOperator extends DataFlow::Node, Decoding::Range {
|
||||||
API::Node dictionary;
|
|
||||||
DataFlow::Node query;
|
DataFlow::Node query;
|
||||||
|
|
||||||
AccumulatorQueryOperator() {
|
AccumulatorQueryOperator() {
|
||||||
|
exists(API::Node dictionary |
|
||||||
dictionary =
|
dictionary =
|
||||||
mongoCollection()
|
mongoCollection()
|
||||||
.getMember("aggregate")
|
.getMember("aggregate")
|
||||||
|
@ -221,6 +222,7 @@ private module PyMongo {
|
||||||
.getSubscript("$accumulator") and
|
.getSubscript("$accumulator") and
|
||||||
query = dictionary.getSubscript(["init", "accumulate", "merge", "finalize"]).asSink() and
|
query = dictionary.getSubscript(["init", "accumulate", "merge", "finalize"]).asSink() and
|
||||||
this = dictionary.asSink()
|
this = dictionary.asSink()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override DataFlow::Node getAnInput() { result = query }
|
override DataFlow::Node getAnInput() { result = query }
|
||||||
|
|
Загрузка…
Ссылка в новой задаче