33 * in an unknown code base.
44 *
55 * 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
77 * `alertQuery` as a `@kind problem` query . This will present
88 * the desired points of interest as alerts that are easily browsable
99 * in a codeql IDE. By itself, this is no different from an ordinary
1212 *
1313 * - points of interest can be added, removed and mixed seamlessly
1414 * - 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`)
1615 *
1716 * A global configuration for the points of interest (see
1817 * `PoIConfg`) can be used to easily manage multiple points of
3736 * override predicate shown(DataFlow::Node n) { n.getFile().getBaseName() = "server-core.js" }
3837 * }
3938 *
40- * class RouteHandlerPoI extends PoI {
39+ * class RouteHandlerPoI extends DefaultEnabledPoI {
4140 * RouteHandlerPoI() { this = "RouteHandlerPoI" }
4241 * override predicate is(DataFlow::Node l0) { l0 instanceof Express::RouteHandler }
4342 * }
4443 *
45- * class RouteSetupAndRouteHandlerPoI extends PoI {
44+ * class RouteSetupAndRouteHandlerPoI extends DefaultEnabledPoI {
4645 * RouteSetupAndRouteHandlerPoI() { this = "RouteSetupAndRouteHandlerPoI" }
4746 *
4847 * override predicate is(DataFlow::Node l0, DataFlow::Node l1, string t1) {
@@ -61,12 +60,20 @@ private import semmle.javascript.RestrictedLocations
6160
6261/**
6362 * 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+ * ```
6471 */
6572private module StandardPoIs {
6673 /**
6774 * An unpromoted route setup candidate.
6875 */
69- class UnpromotedRouteSetupPoI extends StandardPoI {
76+ class UnpromotedRouteSetupPoI extends PoI {
7077 UnpromotedRouteSetupPoI ( ) { this = "UnpromotedRouteSetupPoI" }
7178
7279 override predicate is ( Node l0 ) {
@@ -77,7 +84,7 @@ private module StandardPoIs {
7784 /**
7885 * An unpromoted route handler candidate.
7986 */
80- class UnpromotedRouteHandlerPoI extends StandardPoI {
87+ class UnpromotedRouteHandlerPoI extends PoI {
8188 UnpromotedRouteHandlerPoI ( ) { this = "UnpromotedRouteHandlerPoI" }
8289
8390 override predicate is ( Node l0 ) {
@@ -88,7 +95,7 @@ private module StandardPoIs {
8895 /**
8996 * An unpromoted route handler candidate, with explnatory data flow information.
9097 */
91- class UnpromotedRouteHandlerWithFlowPoI extends StandardPoI {
98+ class UnpromotedRouteHandlerWithFlowPoI extends PoI {
9299 UnpromotedRouteHandlerWithFlowPoI ( ) { this = "UnpromotedRouteHandlerWithFlowPoI" }
93100
94101 private DataFlow:: SourceNode track ( HTTP:: RouteHandlerCandidate cand , DataFlow:: TypeTracker t ) {
@@ -109,7 +116,7 @@ private module StandardPoIs {
109116 /**
110117 * A callee that is unknown.
111118 */
112- class UnknownCalleePoI extends StandardPoI {
119+ class UnknownCalleePoI extends PoI {
113120 UnknownCalleePoI ( ) { this = "UnknownCalleePoI" }
114121
115122 override predicate is ( Node l0 ) {
@@ -120,7 +127,7 @@ private module StandardPoIs {
120127 /**
121128 * A source of remote flow.
122129 */
123- class RemoteFlowSourcePoI extends StandardPoI {
130+ class RemoteFlowSourcePoI extends PoI {
124131 RemoteFlowSourcePoI ( ) { this = "RemoteFlowSourcePoI" }
125132
126133 override predicate is ( Node l0 ) { l0 instanceof RemoteFlowSource }
@@ -129,7 +136,7 @@ private module StandardPoIs {
129136 /**
130137 * A "source" for any active configuration.
131138 */
132- class SourcePoI extends StandardPoI {
139+ class SourcePoI extends PoI {
133140 SourcePoI ( ) { this = "SourcePoI" }
134141
135142 override predicate is ( Node l0 ) {
@@ -140,7 +147,7 @@ private module StandardPoIs {
140147 /**
141148 * A "sink" for any active configuration.
142149 */
143- class SinkPoI extends StandardPoI {
150+ class SinkPoI extends PoI {
144151 SinkPoI ( ) { this = "SinkPoI" }
145152
146153 override predicate is ( Node l0 ) {
@@ -151,7 +158,7 @@ private module StandardPoIs {
151158 /**
152159 * A "barrier" for any active configuration.
153160 */
154- class BarrierPoI extends StandardPoI {
161+ class BarrierPoI extends PoI {
155162 BarrierPoI ( ) { this = "BarrierPoI" }
156163
157164 override predicate is ( Node l0 ) {
@@ -171,7 +178,7 @@ private module StandardPoIs {
171178 /**
172179 * A server-related points of interest.
173180 */
174- class ServerRelatedPoI extends StandardPoI {
181+ class ServerRelatedPoI extends PoI {
175182 ServerRelatedPoI ( ) {
176183 this instanceof UnpromotedRouteSetupPoI or
177184 this instanceof UnpromotedRouteHandlerPoI or
@@ -182,7 +189,7 @@ private module StandardPoIs {
182189 /**
183190 * A configuration-related points of interest.
184191 */
185- class DataFlowConfigurationPoI extends StandardPoI {
192+ class DataFlowConfigurationPoI extends PoI {
186193 DataFlowConfigurationPoI ( ) {
187194 this instanceof SourcePoI or
188195 this instanceof SinkPoI
@@ -196,15 +203,17 @@ private module StandardPoIs {
196203import StandardPoIs
197204
198205/**
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`.
200209 */
201- abstract private class StandardPoI extends PoI {
210+ abstract class DefaultEnabledPoI extends PoI {
202211 bindingset [ this ]
203- StandardPoI ( ) { any ( ) }
212+ DefaultEnabledPoI ( ) { any ( ) }
204213}
205214
206215private module PoIConfigDefaults {
207- predicate enabled ( PoI poi ) { not poi instanceof StandardPoI }
216+ predicate enabled ( PoI poi ) { poi instanceof DefaultEnabledPoI }
208217
209218 predicate shown ( Node n ) { not classify ( n .getFile ( ) , _) }
210219}
0 commit comments