File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
python/ql/src/experimental
semmle/python/security/injection Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 20
20
NoSQL injections can be prevented by escaping user-input's special characters that are passed into the NoSQL query from the user-supplied source.
21
21
Alternatively, using a sanitize library such as MongoSanitizer will ensure that user-supplied sources can not act as a malicious query.
22
22
</p >
23
- <recommendation >
23
+ </ recommendation >
24
24
25
25
<example >
26
26
<p >In the example below, the user-supplied source is passed to a MongoDB function that queries the MongoDB database.</p >
27
27
<sample src =" examples/NoSQLInjection-bad.py" />
28
28
<p > This can be fixed by using a sanitizer library like MongoSanitizer as shown in this annotated code version below.</p >
29
29
<sample src =" examples/NoSQLInjection-good.py" />
30
- <example >
30
+ </ example >
31
31
32
32
<references >
33
33
<li >Mongoengine: <a href =" http://mongoengine.org/" >Documentation</a >.</li >
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class RFSToDictConfig extends TaintTracking::Configuration {
17
17
override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
18
18
19
19
override predicate isSink ( DataFlow:: Node sink ) {
20
- exists ( Decoding decoding | decoding .getFormat ( ) = "JSON" and sink = decoding )
20
+ exists ( Decoding decoding | decoding .getFormat ( ) = "JSON" and sink = decoding . getOutput ( ) )
21
21
}
22
22
23
23
override predicate isSanitizer ( DataFlow:: Node sanitizer ) {
@@ -32,7 +32,7 @@ class FromDataDictToSink extends TaintTracking2::Configuration {
32
32
FromDataDictToSink ( ) { this = "FromDataDictToSink" }
33
33
34
34
override predicate isSource ( DataFlow:: Node source ) {
35
- exists ( Decoding decoding | decoding .getFormat ( ) = "JSON" and source = decoding )
35
+ exists ( Decoding decoding | decoding .getFormat ( ) = "JSON" and source = decoding . getOutput ( ) )
36
36
}
37
37
38
38
override predicate isSink ( DataFlow:: Node sink ) { sink = any ( NoSQLQuery noSQLQuery ) .getQuery ( ) }
You can’t perform that action at this time.
0 commit comments