mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
add some improvements to the bean validation query
This commit is contained in:
@@ -14,6 +14,38 @@ import semmle.code.java.dataflow.TaintTracking
|
|||||||
import semmle.code.java.dataflow.FlowSources
|
import semmle.code.java.dataflow.FlowSources
|
||||||
import DataFlow::PathGraph
|
import DataFlow::PathGraph
|
||||||
|
|
||||||
|
class ELMessageInterpolatorType extends RefType {
|
||||||
|
ELMessageInterpolatorType() {
|
||||||
|
this
|
||||||
|
.getASourceSupertype*()
|
||||||
|
.hasQualifiedName("org.hibernate.validator.messageinterpolation",
|
||||||
|
["ResourceBundleMessageInterpolator", "ValueFormatterMessageInterpolator"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SetSafeMessageInterpolator extends MethodAccess {
|
||||||
|
SetSafeMessageInterpolator() {
|
||||||
|
exists(Method m |
|
||||||
|
this.getMethod() = m and
|
||||||
|
(
|
||||||
|
m
|
||||||
|
.getDeclaringType()
|
||||||
|
.getASourceSupertype*()
|
||||||
|
.hasQualifiedName("javax.validation", ["Configuration", "ValidatorContext"]) and
|
||||||
|
m.getName() = "messageInterpolator"
|
||||||
|
or
|
||||||
|
m
|
||||||
|
.getDeclaringType()
|
||||||
|
.getASourceSupertype*()
|
||||||
|
.hasQualifiedName("org.springframework.validation.beanvalidation",
|
||||||
|
["CustomValidatorBean", "LocalValidatorFactoryBean"]) and
|
||||||
|
m.getName() = "setMessageInterpolator"
|
||||||
|
)
|
||||||
|
) and
|
||||||
|
not this.getAnArgument().getType() instanceof ELMessageInterpolatorType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class BuildConstraintViolationWithTemplateMethod extends Method {
|
class BuildConstraintViolationWithTemplateMethod extends Method {
|
||||||
BuildConstraintViolationWithTemplateMethod() {
|
BuildConstraintViolationWithTemplateMethod() {
|
||||||
this
|
this
|
||||||
@@ -38,5 +70,8 @@ class BeanValidationConfig extends TaintTracking::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
from BeanValidationConfig cfg, DataFlow::PathNode source, DataFlow::PathNode sink
|
from BeanValidationConfig cfg, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||||
where cfg.hasFlowPath(source, sink)
|
where
|
||||||
select sink, source, sink, "Custom constraint error message contains unsanitized user data"
|
not exists(SetSafeMessageInterpolator ma) and
|
||||||
|
cfg.hasFlowPath(source, sink)
|
||||||
|
select sink.getNode(), source, sink,
|
||||||
|
"Custom constraint error message contains unsanitized user data"
|
||||||
|
|||||||
Reference in New Issue
Block a user