mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
Add utility functions definining XSS-vulnerable content-types
This commit is contained in:
@@ -150,3 +150,20 @@ class ServletWriterSource extends MethodAccess {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `s` is an HTTP Content-Type vulnerable to XSS.
|
||||
*/
|
||||
bindingset[s]
|
||||
predicate isXssVulnerableContentType(string s) {
|
||||
s.regexpMatch("(?i)text/(html|xml|xsl|rdf|vtt|cache-manifest).*") or
|
||||
s.regexpMatch("(?i)application/(.*\\+)?xml.*") or
|
||||
s.regexpMatch("(?i)cache-manifest.*") or
|
||||
s.regexpMatch("(?i)image/svg\\+xml.*")
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `s` is an HTTP Content-Type that is not vulnerable to XSS.
|
||||
*/
|
||||
bindingset[s]
|
||||
predicate isXssSafeContentType(string s) { not isXssVulnerableContentType(s) }
|
||||
|
||||
Reference in New Issue
Block a user