13
13
import java
14
14
import semmle.code.java.dataflow.TaintTracking
15
15
import semmle.code.java.dataflow.FlowSources
16
- import DataFlow:: PathGraph
17
16
private import semmle.code.java.dataflow.ExternalFlow
18
17
19
18
/**
@@ -56,14 +55,16 @@ class SetMessageInterpolatorCall extends MethodAccess {
56
55
* Taint tracking BeanValidationConfiguration describing the flow of data from user input
57
56
* to the argument of a method that builds constraint error messages.
58
57
*/
59
- class BeanValidationConfig extends TaintTracking :: Configuration {
60
- BeanValidationConfig ( ) { this = "BeanValidationConfig" }
58
+ private module BeanValidationConfig implements DataFlow :: ConfigSig {
59
+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
61
60
62
- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
63
-
64
- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof BeanValidationSink }
61
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof BeanValidationSink }
65
62
}
66
63
64
+ module BeanValidationFlow = TaintTracking:: Make< BeanValidationConfig > ;
65
+
66
+ import BeanValidationFlow:: PathGraph
67
+
67
68
/**
68
69
* A bean validation sink, such as method `buildConstraintViolationWithTemplate`
69
70
* declared on a subtype of `javax.validation.ConstraintValidatorContext`.
@@ -72,13 +73,13 @@ private class BeanValidationSink extends DataFlow::Node {
72
73
BeanValidationSink ( ) { sinkNode ( this , "bean-validation" ) }
73
74
}
74
75
75
- from BeanValidationConfig cfg , DataFlow :: PathNode source , DataFlow :: PathNode sink
76
+ from BeanValidationFlow :: PathNode source , BeanValidationFlow :: PathNode sink
76
77
where
77
78
(
78
79
not exists ( SetMessageInterpolatorCall c )
79
80
or
80
81
exists ( SetMessageInterpolatorCall c | not c .isSafe ( ) )
81
82
) and
82
- cfg . hasFlowPath ( source , sink )
83
+ BeanValidationFlow :: hasFlowPath ( source , sink )
83
84
select sink .getNode ( ) , source , sink , "Custom constraint error message contains an unsanitized $@." ,
84
85
source , "user-provided value"
0 commit comments