3
3
* in an unknown code base.
4
4
*
5
5
* To use this module, subclass the
6
- * `Poi:: PoI` class, override *one* of its `is` predicates, and use
6
+ * `PoI` class, override *one* of its `is` predicates, and use
7
7
* `alertQuery` as a `@kind problem` query . This will present
8
8
* the desired points of interest as alerts that are easily browsable
9
9
* in a codeql IDE. By itself, this is no different from an ordinary
12
12
*
13
13
* - points of interest can be added, removed and mixed seamlessly
14
14
* - this module comes with a collection of standard points of interest (see `StandardPoIs`)
15
- * - this modules comes with groupings of related points of interest (see `StandardPoIConfigurations`)
16
15
*
17
16
* A global configuration for the points of interest (see
18
17
* `PoIConfg`) can be used to easily manage multiple points of
37
36
* override predicate shown(DataFlow::Node n) { n.getFile().getBaseName() = "server-core.js" }
38
37
* }
39
38
*
40
- * class RouteHandlerPoI extends PoI {
39
+ * class RouteHandlerPoI extends DefaultEnabledPoI {
41
40
* RouteHandlerPoI() { this = "RouteHandlerPoI" }
42
41
* override predicate is(DataFlow::Node l0) { l0 instanceof Express::RouteHandler }
43
42
* }
44
43
*
45
- * class RouteSetupAndRouteHandlerPoI extends PoI {
44
+ * class RouteSetupAndRouteHandlerPoI extends DefaultEnabledPoI {
46
45
* RouteSetupAndRouteHandlerPoI() { this = "RouteSetupAndRouteHandlerPoI" }
47
46
*
48
47
* override predicate is(DataFlow::Node l0, DataFlow::Node l1, string t1) {
@@ -61,12 +60,20 @@ private import semmle.javascript.RestrictedLocations
61
60
62
61
/**
63
62
* Provides often used points of interest.
63
+ *
64
+ * Note that these points of interest should not extend
65
+ * `DefaultEnabledPoI`, and that they can be enabled by default on
66
+ * demand like this:
67
+ *
68
+ * ```
69
+ * class MyPoI extends ServerRelatedPoI, DefaultEnabledPoI {}
70
+ * ```
64
71
*/
65
72
private module StandardPoIs {
66
73
/**
67
74
* An unpromoted route setup candidate.
68
75
*/
69
- class UnpromotedRouteSetupPoI extends StandardPoI {
76
+ class UnpromotedRouteSetupPoI extends PoI {
70
77
UnpromotedRouteSetupPoI ( ) { this = "UnpromotedRouteSetupPoI" }
71
78
72
79
override predicate is ( Node l0 ) {
@@ -77,7 +84,7 @@ private module StandardPoIs {
77
84
/**
78
85
* An unpromoted route handler candidate.
79
86
*/
80
- class UnpromotedRouteHandlerPoI extends StandardPoI {
87
+ class UnpromotedRouteHandlerPoI extends PoI {
81
88
UnpromotedRouteHandlerPoI ( ) { this = "UnpromotedRouteHandlerPoI" }
82
89
83
90
override predicate is ( Node l0 ) {
@@ -88,7 +95,7 @@ private module StandardPoIs {
88
95
/**
89
96
* An unpromoted route handler candidate, with explnatory data flow information.
90
97
*/
91
- class UnpromotedRouteHandlerWithFlowPoI extends StandardPoI {
98
+ class UnpromotedRouteHandlerWithFlowPoI extends PoI {
92
99
UnpromotedRouteHandlerWithFlowPoI ( ) { this = "UnpromotedRouteHandlerWithFlowPoI" }
93
100
94
101
private DataFlow:: SourceNode track ( HTTP:: RouteHandlerCandidate cand , DataFlow:: TypeTracker t ) {
@@ -109,7 +116,7 @@ private module StandardPoIs {
109
116
/**
110
117
* A callee that is unknown.
111
118
*/
112
- class UnknownCalleePoI extends StandardPoI {
119
+ class UnknownCalleePoI extends PoI {
113
120
UnknownCalleePoI ( ) { this = "UnknownCalleePoI" }
114
121
115
122
override predicate is ( Node l0 ) {
@@ -120,7 +127,7 @@ private module StandardPoIs {
120
127
/**
121
128
* A source of remote flow.
122
129
*/
123
- class RemoteFlowSourcePoI extends StandardPoI {
130
+ class RemoteFlowSourcePoI extends PoI {
124
131
RemoteFlowSourcePoI ( ) { this = "RemoteFlowSourcePoI" }
125
132
126
133
override predicate is ( Node l0 ) { l0 instanceof RemoteFlowSource }
@@ -129,7 +136,7 @@ private module StandardPoIs {
129
136
/**
130
137
* A "source" for any active configuration.
131
138
*/
132
- class SourcePoI extends StandardPoI {
139
+ class SourcePoI extends PoI {
133
140
SourcePoI ( ) { this = "SourcePoI" }
134
141
135
142
override predicate is ( Node l0 ) {
@@ -140,7 +147,7 @@ private module StandardPoIs {
140
147
/**
141
148
* A "sink" for any active configuration.
142
149
*/
143
- class SinkPoI extends StandardPoI {
150
+ class SinkPoI extends PoI {
144
151
SinkPoI ( ) { this = "SinkPoI" }
145
152
146
153
override predicate is ( Node l0 ) {
@@ -151,7 +158,7 @@ private module StandardPoIs {
151
158
/**
152
159
* A "barrier" for any active configuration.
153
160
*/
154
- class BarrierPoI extends StandardPoI {
161
+ class BarrierPoI extends PoI {
155
162
BarrierPoI ( ) { this = "BarrierPoI" }
156
163
157
164
override predicate is ( Node l0 ) {
@@ -171,7 +178,7 @@ private module StandardPoIs {
171
178
/**
172
179
* A server-related points of interest.
173
180
*/
174
- class ServerRelatedPoI extends StandardPoI {
181
+ class ServerRelatedPoI extends PoI {
175
182
ServerRelatedPoI ( ) {
176
183
this instanceof UnpromotedRouteSetupPoI or
177
184
this instanceof UnpromotedRouteHandlerPoI or
@@ -182,7 +189,7 @@ private module StandardPoIs {
182
189
/**
183
190
* A configuration-related points of interest.
184
191
*/
185
- class DataFlowConfigurationPoI extends StandardPoI {
192
+ class DataFlowConfigurationPoI extends PoI {
186
193
DataFlowConfigurationPoI ( ) {
187
194
this instanceof SourcePoI or
188
195
this instanceof SinkPoI
@@ -196,15 +203,17 @@ private module StandardPoIs {
196
203
import StandardPoIs
197
204
198
205
/**
199
- * A tagging interface for the standard points of interest.
206
+ * A tagging interface for a custom point of interest that should be
207
+ * enabled in the absence of an explicit
208
+ * `PoIConfiguration::enabled/1`.
200
209
*/
201
- abstract private class StandardPoI extends PoI {
210
+ abstract class DefaultEnabledPoI extends PoI {
202
211
bindingset [ this ]
203
- StandardPoI ( ) { any ( ) }
212
+ DefaultEnabledPoI ( ) { any ( ) }
204
213
}
205
214
206
215
private module PoIConfigDefaults {
207
- predicate enabled ( PoI poi ) { not poi instanceof StandardPoI }
216
+ predicate enabled ( PoI poi ) { poi instanceof DefaultEnabledPoI }
208
217
209
218
predicate shown ( Node n ) { not classify ( n .getFile ( ) , _) }
210
219
}
0 commit comments