File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
javascript/ql/src/semmle/javascript/security/dataflow Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -271,16 +271,19 @@ module ReflectedXss {
271271 * a content type that does not (case-insensitively) contain the string "html". This
272272 * is to prevent us from flagging plain-text or JSON responses as vulnerable.
273273 */
274- private class HttpResponseSink extends Sink {
275- HttpResponseSink ( ) {
276- exists ( HTTP:: ResponseSendArgument sendarg | sendarg = asExpr ( ) |
277- forall ( HTTP:: HeaderDefinition hd |
278- hd = sendarg .getRouteHandler ( ) .getAResponseHeader ( "content-type" )
279- |
280- exists ( string tp | hd .defines ( "content-type" , tp ) | tp .toLowerCase ( ) .matches ( "%html%" ) )
281- )
282- )
283- }
274+ private class HttpResponseSink extends Sink , DataFlow:: ValueNode {
275+ override HTTP:: ResponseSendArgument astNode ;
276+
277+ HttpResponseSink ( ) { not nonHtmlContentType ( astNode .getRouteHandler ( ) ) }
278+ }
279+
280+ /**
281+ * Holds if `h` may send a response with a content type other than HTML.
282+ */
283+ private predicate nonHtmlContentType ( HTTP:: RouteHandler h ) {
284+ exists ( HTTP:: HeaderDefinition hd | hd = h .getAResponseHeader ( "content-type" ) |
285+ not exists ( string tp | hd .defines ( "content-type" , tp ) | tp .regexpMatch ( "(?i).*html.*" ) )
286+ )
284287 }
285288
286289 /**
You can’t perform that action at this time.
0 commit comments