Skip to content

Commit e6e2b67

Browse files
committed
step 1.2
1 parent ebbacd2 commit e6e2b67

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

codeql-custom-queries-java/ctf4.ql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,25 @@ module Bonus {
149149
}
150150
}
151151

152+
/* Step 1.2 */
153+
/** The type `javax.validation.ConstraintValidatorContext`. */
154+
class TypeConstraintValidatorContext extends RefType {
155+
TypeConstraintValidatorContext() {
156+
this.hasQualifiedName("javax.validation", "ConstraintValidatorContext")
157+
}
158+
}
159+
160+
/**
161+
* A method named `buildConstraintViolationWithTemplate` declared on a subtype
162+
* of `javax.validation.ConstraintValidatorContext`.
163+
*/
164+
class BuildConstraintViolationWithTemplateMethod extends Method {
165+
BuildConstraintViolationWithTemplateMethod() {
166+
this.getDeclaringType().getASupertype*() instanceof TypeConstraintValidatorContext and
167+
this.hasName("buildConstraintViolationWithTemplate")
168+
}
169+
}
170+
152171
predicate isSource(DataFlow::Node source) {
153172
/* TODO describe source */
154173
//source.asExpr() instanceof StringLiteral
@@ -159,6 +178,14 @@ predicate isSource(DataFlow::Node source) {
159178
source instanceof BeanValidationSource
160179
}
161180

181+
/* Step 1.2 */
182+
predicate isSink(DataFlow::Node sink) {
183+
exists(MethodAccess ma |
184+
ma.getMethod() instanceof BuildConstraintViolationWithTemplateMethod and
185+
sink.asExpr() = ma.getArgument(0)
186+
)
187+
}
188+
162189
// from Method method, MethodAccess call
163190
// where
164191
// call.getMethod() = method and

0 commit comments

Comments
 (0)