Skip to content

Commit 2a1b2db

Browse files
author
Alvaro Muñoz
committed
Deprecate previous version
1 parent 5c412b9 commit 2a1b2db

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/ReflectedXssCustomizations.qll

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ module ReflectedXss {
2828
HttpResponseSink() { not exists(getAXssSafeHeaderDefinition(this)) }
2929
}
3030

31+
/**
32+
* DEPRECATED: Gets a HeaderDefinition that defines a XSS safe content-type for `send`.
33+
*/
34+
deprecated Http::HeaderDefinition getANonHtmlHeaderDefinition(Http::ResponseSendArgument send) {
35+
exists(Http::RouteHandler h |
36+
send.getRouteHandler() = h and
37+
result = xssSafeContentTypeHeader(h)
38+
|
39+
// The HeaderDefinition affects a response sent at `send`.
40+
headerAffects(result, send)
41+
)
42+
}
43+
3144
/**
3245
* Gets a HeaderDefinition that defines a XSS safe content-type for `send`.
3346
*/
@@ -42,7 +55,7 @@ module ReflectedXss {
4255
}
4356

4457
/**
45-
* A content-type that may lead to javascript code being executed in the browser.
58+
* Gets a content-type that may lead to javascript code being executed in the browser.
4659
* ref: https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#content-types
4760
*/
4861
string xssUnsafeContentType() {
@@ -54,6 +67,16 @@ module ReflectedXss {
5467
]
5568
}
5669

70+
/**
71+
* DEPRECATED: Holds if `h` may send a response with a content type that is safe for XSS.
72+
*/
73+
deprecated Http::HeaderDefinition nonHtmlContentTypeHeader(Http::RouteHandler h) {
74+
result = h.getAResponseHeader("content-type") and
75+
not exists(string tp | result.defines("content-type", tp) |
76+
tp.toLowerCase().matches(xssUnsafeContentType() + "%")
77+
)
78+
}
79+
5780
/**
5881
* Holds if `h` may send a response with a content type that is safe for XSS.
5982
*/

0 commit comments

Comments
 (0)