Skip to content

Commit 3545edb

Browse files
committed
address code review suggestions
1 parent 9db340c commit 3545edb

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

java/ql/src/Security/CWE/CWE-094/InsecureBeanValidation.ql

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ class ELMessageInterpolatorType extends RefType {
2323
}
2424
}
2525

26-
class SetSafeMessageInterpolator extends MethodAccess {
27-
SetSafeMessageInterpolator() {
28-
exists(Method m |
26+
/**
27+
* A method call that sets the application's default message interpolator to an interpolator type that is likely to be safe,
28+
* because it does not process Java Expression Language expressions.
29+
*/
30+
class SetSafeMessageInterpolatorCall extends MethodAccess {
31+
SetSafeMessageInterpolatorCall() {
32+
exists(Method m, RefType t |
2933
this.getMethod() = m and
34+
m.getDeclaringType().getASourceSupertype*() = t and
3035
(
31-
m
32-
.getDeclaringType()
33-
.getASourceSupertype*()
34-
.hasQualifiedName("javax.validation", ["Configuration", "ValidatorContext"]) and
36+
t.hasQualifiedName("javax.validation", ["Configuration", "ValidatorContext"]) and
3537
m.getName() = "messageInterpolator"
3638
or
37-
m
38-
.getDeclaringType()
39-
.getASourceSupertype*()
39+
t
4040
.hasQualifiedName("org.springframework.validation.beanvalidation",
4141
["CustomValidatorBean", "LocalValidatorFactoryBean"]) and
4242
m.getName() = "setMessageInterpolator"
@@ -71,7 +71,7 @@ class BeanValidationConfig extends TaintTracking::Configuration {
7171

7272
from BeanValidationConfig cfg, DataFlow::PathNode source, DataFlow::PathNode sink
7373
where
74-
not exists(SetSafeMessageInterpolator ma) and
74+
not exists(SetSafeMessageInterpolatorCall ma) and
7575
cfg.hasFlowPath(source, sink)
7676
select sink.getNode(), source, sink,
7777
"Custom constraint error message contains unsanitized user data"

0 commit comments

Comments
 (0)