-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathNoSQL.qll
More file actions
48 lines (43 loc) · 1.48 KB
/
NoSQL.qll
File metadata and controls
48 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Provides classes for working with NoSQL-related concepts such as queries.
*/
overlay[local?]
module;
import go
/** Provides classes for working with NoSql-related APIs. */
module NoSql {
/**
* A data-flow node whose value is interpreted as (part of) a NoSQL query.
*
* Extend this class to refine existing API models. If you want to model new APIs,
* extend `NoSQL::Query::Range` instead.
*/
class Query extends DataFlow::Node instanceof Query::Range { }
/** Provides classes for working with NoSql queries. */
module Query {
/**
* A data-flow node whose value is interpreted as (part of) a NoSQL query.
*
* Extend this class to model new APIs. If you want to refine existing API models,
* extend `NoSQL::Query` instead.
*/
abstract class Range extends DataFlow::Node { }
private class ExternalQueryString extends Range {
ExternalQueryString() {
exists(DataFlow::ArgumentNode arg | sinkNode(arg, "nosql-injection") |
this = arg.getACorrespondingSyntacticArgument()
)
}
}
}
/**
* Holds if taint flows from `pred` to `succ` through a MongoDB-specific API.
*/
predicate isAdditionalMongoTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
// Taint an entry if the `Value` is tainted
exists(Write w, Field f | w.writesField(succ, f, pred) |
succ.getType().hasQualifiedName(package("go.mongodb.org/mongo-driver", "bson/primitive"), "E") and
f.getName() = "Value"
)
}
}