File tree Expand file tree Collapse file tree 2 files changed +29
-19
lines changed
python/ql/lib/semmle/python/frameworks Expand file tree Collapse file tree 2 files changed +29
-19
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides classes modeling security-relevant aspects of the PyMongo bindings.
3
+ */
4
+
5
+ private import python
6
+ private import semmle.python.dataflow.new.DataFlow
7
+ private import semmle.python.Concepts
8
+ private import semmle.python.ApiGraphs
9
+
10
+ module BSon {
11
+ /**
12
+ * ObjectId returns a string representing an id.
13
+ * If at any time ObjectId can't parse it's input (like when a tainted dict in passed in),
14
+ * then ObjectId will throw an error preventing the query from running.
15
+ */
16
+ private class BsonObjectIdCall extends DataFlow:: CallCfgNode , NoSqlSanitizer:: Range {
17
+ BsonObjectIdCall ( ) {
18
+ exists ( API:: Node mod |
19
+ mod = API:: moduleImport ( "bson" )
20
+ or
21
+ mod = API:: moduleImport ( "bson" ) .getMember ( [ "objectid" , "json_util" ] )
22
+ |
23
+ this = mod .getMember ( "ObjectId" ) .getACall ( )
24
+ )
25
+ }
26
+
27
+ override DataFlow:: Node getAnInput ( ) { result = this .getArg ( 0 ) }
28
+ }
29
+ }
Original file line number Diff line number Diff line change @@ -274,25 +274,6 @@ private module PyMongo {
274
274
override DataFlow:: Node getAnInput ( ) { result = this .getArg ( 0 ) }
275
275
}
276
276
277
- /**
278
- * ObjectId returns a string representing an id.
279
- * If at any time ObjectId can't parse it's input (like when a tainted dict in passed in),
280
- * then ObjectId will throw an error preventing the query from running.
281
- */
282
- private class BsonObjectIdCall extends DataFlow:: CallCfgNode , NoSqlSanitizer:: Range {
283
- BsonObjectIdCall ( ) {
284
- exists ( API:: Node mod |
285
- mod = API:: moduleImport ( "bson" )
286
- or
287
- mod = API:: moduleImport ( "bson" ) .getMember ( [ "objectid" , "json_util" ] )
288
- |
289
- this = mod .getMember ( "ObjectId" ) .getACall ( )
290
- )
291
- }
292
-
293
- override DataFlow:: Node getAnInput ( ) { result = this .getArg ( 0 ) }
294
- }
295
-
296
277
/**
297
278
* An equality operator can protect against dictionary interpretation.
298
279
* For instance, in `{'password': {"$eq": password} }`, if a dictionary is injected into
You can’t perform that action at this time.
0 commit comments