Skip to content

Commit f6a99cb

Browse files
committed
Java: Model produces parameter to RequestMapping attribute.
1 parent 8057dff commit f6a99cb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

java/ql/src/semmle/code/java/frameworks/spring/SpringController.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ class SpringResponseBodyAnnotationType extends AnnotationType {
105105
* A method on a Spring controller that is executed in response to a web request.
106106
*/
107107
class SpringRequestMappingMethod extends SpringControllerMethod {
108+
Annotation requestMappingAnnotation;
108109
SpringRequestMappingMethod() {
109110
// Any method that declares the @RequestMapping annotation, or overrides a method that declares
110111
// the annotation. We have to do this explicit check because the @RequestMapping annotation is
111112
// not declared with @Inherited.
112113
exists(Method superMethod |
113114
this.overrides*(superMethod) and
114-
superMethod.getAnAnnotation().getType() instanceof SpringRequestMappingAnnotationType
115+
requestMappingAnnotation = superMethod.getAnAnnotation() and
116+
requestMappingAnnotation.getType() instanceof SpringRequestMappingAnnotationType
115117
)
116118
}
117119

@@ -120,6 +122,11 @@ class SpringRequestMappingMethod extends SpringControllerMethod {
120122
result = getAParameter()
121123
}
122124

125+
/** Gets the "produces" @RequestMapping annotation value, if present. */
126+
string getProduces() {
127+
result = requestMappingAnnotation.getValue("produces").(StringLiteral).getValue()
128+
}
129+
123130
/** Holds if this is considered an @ResponseBody method. */
124131
predicate isResponseBody() {
125132
getAnAnnotation().getType() instanceof SpringResponseBodyAnnotationType

0 commit comments

Comments
 (0)