@@ -154,113 +154,12 @@ deprecated module DomBasedXss {
154154 import DomBasedXssCustomizations:: DomBasedXss
155155}
156156
157- /** Provides classes and predicates for the reflected XSS query. */
158- module ReflectedXss {
159- /** A data flow source for reflected XSS vulnerabilities. */
160- abstract class Source extends Shared:: Source { }
161-
162- /** A data flow sink for reflected XSS vulnerabilities. */
163- abstract class Sink extends Shared:: Sink { }
164-
165- /** A sanitizer for reflected XSS vulnerabilities. */
166- abstract class Sanitizer extends Shared:: Sanitizer { }
167-
168- /** A sanitizer guard for reflected XSS vulnerabilities. */
169- abstract class SanitizerGuard extends Shared:: SanitizerGuard { }
170-
171- /**
172- * An expression that is sent as part of an HTTP response, considered as an XSS sink.
173- *
174- * We exclude cases where the route handler sets either an unknown content type or
175- * a content type that does not (case-insensitively) contain the string "html". This
176- * is to prevent us from flagging plain-text or JSON responses as vulnerable.
177- */
178- class HttpResponseSink extends Sink , DataFlow:: ValueNode {
179- override HTTP:: ResponseSendArgument astNode ;
180-
181- HttpResponseSink ( ) { not exists ( getANonHtmlHeaderDefinition ( astNode ) ) }
182- }
183-
184- /**
185- * Gets a HeaderDefinition that defines a non-html content-type for `send`.
186- */
187- HTTP:: HeaderDefinition getANonHtmlHeaderDefinition ( HTTP:: ResponseSendArgument send ) {
188- exists ( HTTP:: RouteHandler h |
189- send .getRouteHandler ( ) = h and
190- result = nonHtmlContentTypeHeader ( h )
191- |
192- // The HeaderDefinition affects a response sent at `send`.
193- headerAffects ( result , send )
194- )
195- }
196-
197- /**
198- * Holds if `h` may send a response with a content type other than HTML.
199- */
200- HTTP:: HeaderDefinition nonHtmlContentTypeHeader ( HTTP:: RouteHandler h ) {
201- result = h .getAResponseHeader ( "content-type" ) and
202- not exists ( string tp | result .defines ( "content-type" , tp ) | tp .regexpMatch ( "(?i).*html.*" ) )
203- }
204-
205- /**
206- * Holds if a header set in `header` is likely to affect a response sent at `sender`.
207- */
208- predicate headerAffects ( HTTP:: HeaderDefinition header , HTTP:: ResponseSendArgument sender ) {
209- sender .getRouteHandler ( ) = header .getRouteHandler ( ) and
210- (
211- // `sender` is affected by a dominating `header`.
212- header .getBasicBlock ( ) .( ReachableBasicBlock ) .dominates ( sender .getBasicBlock ( ) )
213- or
214- // There is no dominating header, and `header` is non-local.
215- not isLocalHeaderDefinition ( header ) and
216- not exists ( HTTP:: HeaderDefinition dominatingHeader |
217- dominatingHeader .getBasicBlock ( ) .( ReachableBasicBlock ) .dominates ( sender .getBasicBlock ( ) )
218- )
219- )
220- }
221-
222- /**
223- * Holds if the HeaderDefinition `header` seems to be local.
224- * A HeaderDefinition is local if it dominates exactly one `ResponseSendArgument`.
225- *
226- * Recognizes variants of:
227- * ```
228- * response.writeHead(500, ...);
229- * response.end('Some error');
230- * return;
231- * ```
232- */
233- predicate isLocalHeaderDefinition ( HTTP:: HeaderDefinition header ) {
234- exists ( ReachableBasicBlock headerBlock | headerBlock = header .getBasicBlock ( ) |
235- 1 =
236- strictcount ( HTTP:: ResponseSendArgument sender |
237- sender .getRouteHandler ( ) = header .getRouteHandler ( ) and
238- header .getBasicBlock ( ) .( ReachableBasicBlock ) .dominates ( sender .getBasicBlock ( ) )
239- ) and
240- // doesn't dominate something that looks like a callback.
241- not exists ( Expr e | e instanceof Function | headerBlock .dominates ( e .getBasicBlock ( ) ) )
242- )
243- }
244-
245- /**
246- * A regexp replacement involving an HTML meta-character, viewed as a sanitizer for
247- * XSS vulnerabilities.
248- *
249- * The XSS queries do not attempt to reason about correctness or completeness of sanitizers,
250- * so any such replacement stops taint propagation.
251- */
252- private class MetacharEscapeSanitizer extends Sanitizer , Shared:: MetacharEscapeSanitizer { }
253-
254- private class UriEncodingSanitizer extends Sanitizer , Shared:: UriEncodingSanitizer { }
255-
256- private class SerializeJavascriptSanitizer extends Sanitizer , Shared:: SerializeJavascriptSanitizer {
257- }
258-
259- private class IsEscapedInSwitchSanitizer extends Sanitizer , Shared:: IsEscapedInSwitchSanitizer { }
260-
261- private class QuoteGuard extends SanitizerGuard , Shared:: QuoteGuard { }
262-
263- private class ContainsHtmlGuard extends SanitizerGuard , Shared:: ContainsHtmlGuard { }
157+ /**
158+ * DEPRECATED: Use the `DomBasedXssCustomizations.qll` file instead.
159+ * Provides classes and predicates for the reflected XSS query.
160+ */
161+ deprecated module ReflectedXss {
162+ import ReflectedXssCustomizations:: ReflectedXss
264163}
265164
266165/** Provides classes and predicates for the stored XSS query. */
0 commit comments