11import java
22private import semmle.code.java.dataflow.ExternalFlow
33
4- string getAJaxWsPackage ( ) { result in [ "javax.ws.rs" , "jakarta.ws.rs" ] }
4+ /**
5+ * Gets a name for the root package of JAX-RS.
6+ */
7+ string getAJaxRsPackage ( ) { result in [ "javax.ws.rs" , "jakarta.ws.rs" ] }
58
9+ /**
10+ * Gets a name for package `subpackage` within the JAX-RS hierarchy.
11+ */
612bindingset [ subpackage]
7- string getAJaxWsPackage ( string subpackage ) { result = getAJaxWsPackage ( ) + "." + subpackage }
13+ string getAJaxRsPackage ( string subpackage ) { result = getAJaxRsPackage ( ) + "." + subpackage }
814
915/**
1016 * A JAX WS endpoint is constructed by the container, and its methods
@@ -34,7 +40,7 @@ class JaxWsEndpoint extends Class {
3440private predicate hasPathAnnotation ( Annotatable annotatable ) {
3541 exists ( AnnotationType a |
3642 a = annotatable .getAnAnnotation ( ) .getType ( ) and
37- a .getPackage ( ) .getName ( ) = getAJaxWsPackage ( )
43+ a .getPackage ( ) .getName ( ) = getAJaxRsPackage ( )
3844 |
3945 a .hasName ( "Path" )
4046 )
@@ -47,7 +53,7 @@ class JaxRsResourceMethod extends Method {
4753 JaxRsResourceMethod ( ) {
4854 exists ( AnnotationType a |
4955 a = this .getAnAnnotation ( ) .getType ( ) and
50- a .getPackage ( ) .getName ( ) = getAJaxWsPackage ( )
56+ a .getPackage ( ) .getName ( ) = getAJaxRsPackage ( )
5157 |
5258 a .hasName ( "GET" ) or
5359 a .hasName ( "POST" ) or
@@ -184,7 +190,7 @@ class JaxRsInjectionAnnotation extends JaxRSAnnotation {
184190 JaxRsInjectionAnnotation ( ) {
185191 exists ( AnnotationType a |
186192 a = getType ( ) and
187- a .getPackage ( ) .getName ( ) = getAJaxWsPackage ( )
193+ a .getPackage ( ) .getName ( ) = getAJaxRsPackage ( )
188194 |
189195 a .hasName ( "BeanParam" ) or
190196 a .hasName ( "CookieParam" ) or
@@ -195,25 +201,25 @@ class JaxRsInjectionAnnotation extends JaxRSAnnotation {
195201 a .hasName ( "QueryParam" )
196202 )
197203 or
198- getType ( ) .hasQualifiedName ( getAJaxWsPackage ( "core" ) , "Context" )
204+ getType ( ) .hasQualifiedName ( getAJaxRsPackage ( "core" ) , "Context" )
199205 }
200206}
201207
202208class JaxRsResponse extends Class {
203- JaxRsResponse ( ) { this .hasQualifiedName ( getAJaxWsPackage ( "core" ) , "Response" ) }
209+ JaxRsResponse ( ) { this .hasQualifiedName ( getAJaxRsPackage ( "core" ) , "Response" ) }
204210}
205211
206212class JaxRsResponseBuilder extends Class {
207213 JaxRsResponseBuilder ( ) {
208- this .hasQualifiedName ( getAJaxWsPackage ( "core" ) , "Response$ResponseBuilder" )
214+ this .hasQualifiedName ( getAJaxRsPackage ( "core" ) , "Response$ResponseBuilder" )
209215 }
210216}
211217
212218/**
213219 * The class `javax.ws.rs.client.Client`.
214220 */
215221class JaxRsClient extends RefType {
216- JaxRsClient ( ) { this .hasQualifiedName ( getAJaxWsPackage ( "client" ) , "Client" ) }
222+ JaxRsClient ( ) { this .hasQualifiedName ( getAJaxRsPackage ( "client" ) , "Client" ) }
217223}
218224
219225/**
@@ -226,7 +232,7 @@ class JaxRsBeanParamConstructor extends Constructor {
226232 c = resourceClass .getAnInjectableCallable ( )
227233 |
228234 p = c .getAParameter ( ) and
229- p .getAnAnnotation ( ) .getType ( ) .hasQualifiedName ( getAJaxWsPackage ( ) , "BeanParam" ) and
235+ p .getAnAnnotation ( ) .getType ( ) .hasQualifiedName ( getAJaxRsPackage ( ) , "BeanParam" ) and
230236 this .getDeclaringType ( ) .getSourceDeclaration ( ) = p .getType ( ) .( RefType ) .getSourceDeclaration ( )
231237 ) and
232238 forall ( Parameter p | p = getAParameter ( ) |
@@ -239,7 +245,7 @@ class JaxRsBeanParamConstructor extends Constructor {
239245 * The class `javax.ws.rs.ext.MessageBodyReader`.
240246 */
241247class MessageBodyReader extends GenericInterface {
242- MessageBodyReader ( ) { this .hasQualifiedName ( getAJaxWsPackage ( "ext" ) , "MessageBodyReader" ) }
248+ MessageBodyReader ( ) { this .hasQualifiedName ( getAJaxRsPackage ( "ext" ) , "MessageBodyReader" ) }
243249}
244250
245251/**
@@ -265,7 +271,7 @@ class MessageBodyReaderRead extends Method {
265271
266272/** An `@Produces` annotation that describes which content types can be produced by this resource. */
267273class JaxRSProducesAnnotation extends JaxRSAnnotation {
268- JaxRSProducesAnnotation ( ) { getType ( ) .hasQualifiedName ( getAJaxWsPackage ( ) , "Produces" ) }
274+ JaxRSProducesAnnotation ( ) { getType ( ) .hasQualifiedName ( getAJaxRsPackage ( ) , "Produces" ) }
269275
270276 /**
271277 * Gets a declared content type that can be produced by this resource.
@@ -276,7 +282,7 @@ class JaxRSProducesAnnotation extends JaxRSAnnotation {
276282 exists ( Field jaxMediaType |
277283 // Accesses to static fields on `MediaType` class do not have constant strings in the database
278284 // so convert the field name to a content type string
279- jaxMediaType .getDeclaringType ( ) .hasQualifiedName ( getAJaxWsPackage ( "core" ) , "MediaType" ) and
285+ jaxMediaType .getDeclaringType ( ) .hasQualifiedName ( getAJaxRsPackage ( "core" ) , "MediaType" ) and
280286 jaxMediaType .getAnAccess ( ) = getAValue ( ) and
281287 // e.g. MediaType.TEXT_PLAIN => text/plain
282288 result = jaxMediaType .getName ( ) .toLowerCase ( ) .replaceAll ( "_" , "/" )
@@ -286,7 +292,7 @@ class JaxRSProducesAnnotation extends JaxRSAnnotation {
286292
287293/** An `@Consumes` annotation that describes content types can be consumed by this resource. */
288294class JaxRSConsumesAnnotation extends JaxRSAnnotation {
289- JaxRSConsumesAnnotation ( ) { getType ( ) .hasQualifiedName ( getAJaxWsPackage ( ) , "Consumes" ) }
295+ JaxRSConsumesAnnotation ( ) { getType ( ) .hasQualifiedName ( getAJaxRsPackage ( ) , "Consumes" ) }
290296}
291297
292298/**
0 commit comments