mirror of
https://github.com/github/codeql.git
synced 2026-04-17 04:54:02 +02:00
Allow jax-rs path annotation inheritance
This commit is contained in:
@@ -147,6 +147,20 @@ private predicate hasPathAnnotation(Annotatable annotatable) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if the class inherites the JaxRs `@Path` annotation.
|
||||
*/
|
||||
private predicate hasOrInheritsPathAnnotation(Class c) {
|
||||
hasPathAnnotation(c)
|
||||
or
|
||||
// Note that by the JAX-RS spec, JAX-RS annotations on classes and interfaces
|
||||
// are not inherited, but some implementations, like Apache CXF, do inherit
|
||||
// them. I think this only applies if there are no JaxRS annotations on the
|
||||
// class itself.
|
||||
hasPathAnnotation(c.getAnAncestor()) and
|
||||
not exists(c.getAnAnnotation().(JaxRSAnnotation))
|
||||
}
|
||||
|
||||
/**
|
||||
* A method which is annotated with one or more JaxRS resource type annotations e.g. `@GET`, `@POST` etc.
|
||||
*/
|
||||
@@ -191,7 +205,7 @@ class JaxRsResourceMethod extends Method {
|
||||
class JaxRsResourceClass extends Class {
|
||||
JaxRsResourceClass() {
|
||||
// A root resource class has a @Path annotation on the class.
|
||||
hasPathAnnotation(this)
|
||||
hasOrInheritsPathAnnotation(this)
|
||||
or
|
||||
// A sub-resource
|
||||
exists(JaxRsResourceClass resourceClass, Method method |
|
||||
@@ -227,7 +241,7 @@ class JaxRsResourceClass extends Class {
|
||||
/**
|
||||
* Holds if this class is a "root resource" class
|
||||
*/
|
||||
predicate isRootResource() { hasPathAnnotation(this) }
|
||||
predicate isRootResource() { hasOrInheritsPathAnnotation(this) }
|
||||
|
||||
/**
|
||||
* Gets a `Constructor` that may be called by a JaxRS container to construct this class reflectively.
|
||||
|
||||
Reference in New Issue
Block a user