File tree Expand file tree Collapse file tree 4 files changed +9
-5
lines changed
src/semmle/code/java/frameworks
test/library-tests/frameworks/JaxWs Expand file tree Collapse file tree 4 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -283,7 +283,10 @@ class MessageBodyReaderRead extends Method {
283
283
}
284
284
}
285
285
286
- private string getContentTypeString ( Expr e ) {
286
+ /**
287
+ * Gets a constant content-type described by expression `e` (either a string constant or a Jax-RS MediaType field access).
288
+ */
289
+ string getContentTypeString ( Expr e ) {
287
290
result = e .( CompileTimeConstantExpr ) .getStringValue ( ) and
288
291
result != ""
289
292
or
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ int Get() { // $ ResourceMethod ResourceMethodOnResourceClass
71
71
@ Produces ("text/html" ) // $ ProducesAnnotation=text/html
72
72
@ POST
73
73
boolean Post () { // $ ResourceMethod=text/html ResourceMethodOnResourceClass
74
- return false ;
74
+ return false ; // $ XssSink
75
75
}
76
76
77
77
@ Produces (MediaType .TEXT_PLAIN ) // $ ProducesAnnotation=text/plain
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ class JaxRsTest extends InlineExpectationsTest {
25
25
element = resourceMethod .toString ( ) and
26
26
if exists ( resourceMethod .getProducesAnnotation ( ) )
27
27
then
28
- value = resourceMethod .getProducesAnnotation ( ) .getADeclaredContentType ( ) and
28
+ value =
29
+ getContentTypeString ( resourceMethod .getProducesAnnotation ( ) .getADeclaredContentTypeExpr ( ) ) and
29
30
value != ""
30
31
else
31
32
// Filter out empty strings that stem from using stubs.
@@ -143,7 +144,7 @@ class JaxRsTest extends InlineExpectationsTest {
143
144
exists ( JaxRSProducesAnnotation producesAnnotation |
144
145
producesAnnotation .getLocation ( ) = location and
145
146
element = producesAnnotation .toString ( ) and
146
- value = producesAnnotation .getADeclaredContentType ( ) and
147
+ value = getContentTypeString ( producesAnnotation .getADeclaredContentTypeExpr ( ) ) and
147
148
value != ""
148
149
// Filter out empty strings that stem from using stubs.
149
150
// If we built the test against the real JAR then the field
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ int Get() { // $ ResourceMethod ResourceMethodOnResourceClass
71
71
@ Produces ("text/html" ) // $ ProducesAnnotation=text/html
72
72
@ POST
73
73
boolean Post () { // $ ResourceMethod=text/html ResourceMethodOnResourceClass
74
- return false ;
74
+ return false ; // $ XssSink
75
75
}
76
76
77
77
@ Produces (MediaType .TEXT_PLAIN ) // $ ProducesAnnotation=text/plain
You can’t perform that action at this time.
0 commit comments