mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
JavaScript: Improve XSS sanitizer detection.
We now use local data flow to detect more regexp-based sanitizers.
This commit is contained in:
@@ -34,7 +34,7 @@ module Shared {
|
||||
MetacharEscapeSanitizer() {
|
||||
getMethodName() = "replace" and
|
||||
exists(RegExpConstant c |
|
||||
c.getLiteral() = getArgument(0).asExpr() and
|
||||
c.getLiteral() = getArgument(0).getALocalSource().asExpr() and
|
||||
c.getValue().regexpMatch("['\"&<>]")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
function escapeHtml(s) {
|
||||
var amp = /&/g, lt = /</g, gt = />/g;
|
||||
return s.toString()
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
.replace(amp, '&')
|
||||
.replace(lt, '<')
|
||||
.replace(gt, '>');
|
||||
}
|
||||
|
||||
function escapeAttr(s) {
|
||||
|
||||
Reference in New Issue
Block a user