mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
Abstract Xss sanitizer
Turn the Xss sanitizer into an abstract class to support customizations and provide a default implementation.
This commit is contained in:
@@ -22,9 +22,7 @@ class XSSConfig extends TaintTracking::Configuration {
|
|||||||
|
|
||||||
override predicate isSink(DataFlow::Node sink) { sink instanceof XssSink }
|
override predicate isSink(DataFlow::Node sink) { sink instanceof XssSink }
|
||||||
|
|
||||||
override predicate isSanitizer(DataFlow::Node node) {
|
override predicate isSanitizer(DataFlow::Node node) { node instanceof XssSanitizer }
|
||||||
node.getType() instanceof NumericType or node.getType() instanceof BooleanType
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
from DataFlow::PathNode source, DataFlow::PathNode sink, XSSConfig conf
|
from DataFlow::PathNode source, DataFlow::PathNode sink, XSSConfig conf
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import semmle.code.java.dataflow.TaintTracking2
|
|||||||
|
|
||||||
abstract class XssSink extends DataFlow::Node { }
|
abstract class XssSink extends DataFlow::Node { }
|
||||||
|
|
||||||
|
abstract class XssSanitizer extends DataFlow::Node { }
|
||||||
|
|
||||||
private class DefaultXssSink extends XssSink {
|
private class DefaultXssSink extends XssSink {
|
||||||
DefaultXssSink() {
|
DefaultXssSink() {
|
||||||
exists(HttpServletResponseSendErrorMethod m, MethodAccess ma |
|
exists(HttpServletResponseSendErrorMethod m, MethodAccess ma |
|
||||||
@@ -80,6 +82,12 @@ private class DefaultXssSink extends XssSink {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class DefaultXSSSanitizer extends XssSanitizer {
|
||||||
|
DefaultXSSSanitizer() {
|
||||||
|
this.getType() instanceof NumericType or this.getType() instanceof BooleanType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class ServletWriterSourceToWritingMethodFlowConfig extends TaintTracking2::Configuration {
|
private class ServletWriterSourceToWritingMethodFlowConfig extends TaintTracking2::Configuration {
|
||||||
ServletWriterSourceToWritingMethodFlowConfig() {
|
ServletWriterSourceToWritingMethodFlowConfig() {
|
||||||
this = "XSS::ServletWriterSourceToWritingMethodFlowConfig"
|
this = "XSS::ServletWriterSourceToWritingMethodFlowConfig"
|
||||||
|
|||||||
Reference in New Issue
Block a user