Skip to content

Commit 63ee51a

Browse files
committed
Python: inline mongoCollectionMethod
1 parent 70d47f3 commit 63ee51a

File tree

1 file changed

+4
-17
lines changed
  • python/ql/src/experimental/semmle/python/frameworks

1 file changed

+4
-17
lines changed

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,6 @@ private module NoSql {
101101
}
102102
}
103103

104-
/**
105-
* Gets a reference to a `Mongo` collection method.
106-
*
107-
* ```py
108-
* from flask_pymongo import PyMongo
109-
* mongo = PyMongo(app)
110-
* mongo.db.user.find({'name': safe_search})
111-
* ```
112-
*
113-
* `mongo.db.user.find` would be a collection method.
114-
*/
115-
private API::Node mongoCollectionMethod() {
116-
result = mongoCollection().getMember(any(MongoCollectionMethodNames m))
117-
}
118-
119104
/**
120105
* Gets a reference to a `Mongo` collection method call
121106
*
@@ -125,10 +110,12 @@ private module NoSql {
125110
* mongo.db.user.find({'name': safe_search})
126111
* ```
127112
*
128-
* `mongo.db.user.find({'name': safe_search})` would be a collection method call, and so the result.
113+
* `mongo.db.user.find({'name': safe_search})` would be a collection method call.
129114
*/
130115
private class MongoCollectionCall extends DataFlow::CallCfgNode, NoSqlQuery::Range {
131-
MongoCollectionCall() { this = mongoCollectionMethod().getACall() }
116+
MongoCollectionCall() {
117+
this = mongoCollection().getMember(any(MongoCollectionMethodNames m)).getACall()
118+
}
132119

133120
override DataFlow::Node getQuery() { result = this.getArg(0) }
134121
}

0 commit comments

Comments
 (0)