-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathUtils.qll
More file actions
95 lines (84 loc) · 2.43 KB
/
Utils.qll
File metadata and controls
95 lines (84 loc) · 2.43 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* A collection of utility predicates and classes for JavaScript
*/
private import javascript
private import semmle.javascript.security.dataflow.CommandInjectionCustomizations
private import semmle.javascript.security.dataflow.CodeInjectionCustomizations
private import semmle.javascript.security.dataflow.LogInjectionQuery as LogInjection
private import semmle.javascript.security.dataflow.NosqlInjectionCustomizations
private import semmle.javascript.security.dataflow.SqlInjectionCustomizations
private import semmle.javascript.security.dataflow.Xss as Xss
private import semmle.javascript.security.dataflow.XxeCustomizations
/**
* Filter results to a specific file and line number
*
* **Examples:**
*
* ```
* filterByLocation(sources, "db.js", 1)
* // or we don't care about the line numbers
* filterByLocation(sources, "db.js", _)
* ```
*/
predicate filterByLocation(DataFlow::Node node, string relative_path, int linenumber) {
node.getLocation().getFile().getRelativePath() = relative_path and
node.getLocation().getStartLine() = linenumber
}
/**
* All Sources (Remote and Local)
*/
class AllSources extends DataFlow::Node {
private string threadmodel;
AllSources() {
this instanceof RemoteSources and
threadmodel = "remote" or
this instanceof LocalSources and
threadmodel = "local"
}
/**
* Gets the source threat model.
*/
string getThreatModel() {
result = threadmodel
}
}
/**
* Remote Sources (HTTP frameworks, etc)
*/
class RemoteSources extends ThreatModelSource {
RemoteSources() { this.getThreatModel() = "remote" }
}
/**
* Local Sources (CLI arguments, Filesystem, etc)
*/
class LocalSources extends ThreatModelSource {
LocalSources() { this.getThreatModel() = "local" }
}
/**
* List of all sinks
*/
class AllSinks extends DataFlow::Node {
private string sink;
AllSinks() {
this instanceof CodeInjection::Sink and
sink = "code-injection" or
this instanceof CommandInjection::Sink and
sink = "command-injection" or
this instanceof LogInjection::Sink and
sink = "log-injection" or
this instanceof NosqlInjection::Sink and
sink = "nosql-injection" or
this instanceof SqlInjection::Sink and
sink = "sql-injection" or
this instanceof Xss::Shared::Sink and
sink = "xss" or
this instanceof Xxe::Sink and
sink = "xxe"
}
/**
* Gets the sink threat model.
*/
string sinkType() {
result = sink
}
}