mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
Improve reflective class names
This commit is contained in:
@@ -304,7 +304,7 @@ class NewInstance extends MethodCall {
|
||||
}
|
||||
|
||||
/**
|
||||
* A `MethodCall` on a `Class` element.
|
||||
* A `MethodCall` on a `Class` instance.
|
||||
*/
|
||||
class ClassMethodCall extends MethodCall {
|
||||
ClassMethodCall() { this.getCallee().getDeclaringType() instanceof TypeClass }
|
||||
@@ -326,34 +326,34 @@ deprecated class ClassMethodAccess = ClassMethodCall;
|
||||
/**
|
||||
* A call to `Class.getConstructors(..)` or `Class.getDeclaredConstructors(..)`.
|
||||
*/
|
||||
class ReflectiveConstructorsCall extends ClassMethodCall {
|
||||
ReflectiveConstructorsCall() {
|
||||
class ReflectiveGetConstructorsCall extends ClassMethodCall {
|
||||
ReflectiveGetConstructorsCall() {
|
||||
this.getCallee().hasName("getConstructors") or
|
||||
this.getCallee().hasName("getDeclaredConstructors")
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for `ReflectiveConstructorsCall`. */
|
||||
deprecated class ReflectiveConstructorsAccess = ReflectiveConstructorsCall;
|
||||
/** DEPRECATED: Alias for `ReflectiveGetConstructorsCall`. */
|
||||
deprecated class ReflectiveConstructorsAccess = ReflectiveGetConstructorsCall;
|
||||
|
||||
/**
|
||||
* A call to `Class.getMethods(..)` or `Class.getDeclaredMethods(..)`.
|
||||
*/
|
||||
class ReflectiveMethodsCall extends ClassMethodCall {
|
||||
ReflectiveMethodsCall() {
|
||||
class ReflectiveGetMethodsCall extends ClassMethodCall {
|
||||
ReflectiveGetMethodsCall() {
|
||||
this.getCallee().hasName("getMethods") or
|
||||
this.getCallee().hasName("getDeclaredMethods")
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for `ReflectiveMethodsCall`. */
|
||||
deprecated class ReflectiveMethodsAccess = ReflectiveMethodsCall;
|
||||
/** DEPRECATED: Alias for `ReflectiveGetMethodsCall`. */
|
||||
deprecated class ReflectiveMethodsAccess = ReflectiveGetMethodsCall;
|
||||
|
||||
/**
|
||||
* A call to `Class.getMethod(..)` or `Class.getDeclaredMethod(..)`.
|
||||
*/
|
||||
class ReflectiveMethodCall extends ClassMethodCall {
|
||||
ReflectiveMethodCall() {
|
||||
class ReflectiveGetMethodCall extends ClassMethodCall {
|
||||
ReflectiveGetMethodCall() {
|
||||
this.getCallee().hasName("getMethod") or
|
||||
this.getCallee().hasName("getDeclaredMethod")
|
||||
}
|
||||
@@ -378,14 +378,14 @@ class ReflectiveMethodCall extends ClassMethodCall {
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for `ReflectiveMethodCall`. */
|
||||
deprecated class ReflectiveMethodAccess = ReflectiveMethodCall;
|
||||
/** DEPRECATED: Alias for `ReflectiveGetMethodCall`. */
|
||||
deprecated class ReflectiveMethodAccess = ReflectiveGetMethodCall;
|
||||
|
||||
/**
|
||||
* A call to `Class.getAnnotation(..)`.
|
||||
*/
|
||||
class ReflectiveAnnotationCall extends ClassMethodCall {
|
||||
ReflectiveAnnotationCall() { this.getCallee().hasName("getAnnotation") }
|
||||
class ReflectiveGetAnnotationCall extends ClassMethodCall {
|
||||
ReflectiveGetAnnotationCall() { this.getCallee().hasName("getAnnotation") }
|
||||
|
||||
/**
|
||||
* Gets a possible annotation type for this reflective annotation access.
|
||||
@@ -395,14 +395,14 @@ class ReflectiveAnnotationCall extends ClassMethodCall {
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for `ReflectiveAnnotationCall`. */
|
||||
deprecated class ReflectiveAnnotationAccess = ReflectiveAnnotationCall;
|
||||
/** DEPRECATED: Alias for `ReflectiveGetAnnotationCall`. */
|
||||
deprecated class ReflectiveAnnotationAccess = ReflectiveGetAnnotationCall;
|
||||
|
||||
/**
|
||||
* A call to `Class.getField(..)` that accesses a field.
|
||||
*/
|
||||
class ReflectiveFieldCall extends ClassMethodCall {
|
||||
ReflectiveFieldCall() {
|
||||
class ReflectiveGetFieldCall extends ClassMethodCall {
|
||||
ReflectiveGetFieldCall() {
|
||||
this.getCallee().hasName("getField") or
|
||||
this.getCallee().hasName("getDeclaredField")
|
||||
}
|
||||
@@ -424,5 +424,5 @@ class ReflectiveFieldCall extends ClassMethodCall {
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for `ReflectiveFieldCall`. */
|
||||
deprecated class ReflectiveFieldAccess = ReflectiveFieldCall;
|
||||
/** DEPRECATED: Alias for `ReflectiveGetFieldCall`. */
|
||||
deprecated class ReflectiveFieldAccess = ReflectiveGetFieldCall;
|
||||
|
||||
@@ -267,7 +267,7 @@ private module Impl {
|
||||
|
||||
/** Holds if `f` can have any sign. */
|
||||
predicate fieldWithUnknownSign(Field f) {
|
||||
exists(ReflectiveFieldCall rfa | rfa.inferAccessedField() = f)
|
||||
exists(ReflectiveGetFieldCall rfa | rfa.inferAccessedField() = f)
|
||||
}
|
||||
|
||||
/** Holds if `f` is accessed in an increment operation. */
|
||||
|
||||
@@ -173,7 +173,7 @@ class LiveClass extends SourceClassOrInterface {
|
||||
exists(NestedType r | r.getEnclosingType() = this | r instanceof LiveClass)
|
||||
or
|
||||
// An annotation on the class is reflectively accessed.
|
||||
exists(ReflectiveAnnotationCall reflectiveAnnotationCall |
|
||||
exists(ReflectiveGetAnnotationCall reflectiveAnnotationCall |
|
||||
this = reflectiveAnnotationCall.getInferredClassType() and
|
||||
isLive(reflectiveAnnotationCall.getEnclosingCallable())
|
||||
)
|
||||
|
||||
@@ -130,7 +130,7 @@ class JUnitAnnotatedField extends ReflectivelyReadField {
|
||||
*/
|
||||
class ClassReflectivelyReadField extends ReflectivelyReadField {
|
||||
ClassReflectivelyReadField() {
|
||||
exists(ReflectiveFieldCall fieldAccess | this = fieldAccess.inferAccessedField())
|
||||
exists(ReflectiveGetFieldCall fieldAccess | this = fieldAccess.inferAccessedField())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ class NewInstanceCall extends EntryPoint, NewInstance {
|
||||
/**
|
||||
* A call to either `Class.getMethod(...)` or `Class.getDeclaredMethod(...)`.
|
||||
*/
|
||||
class ReflectiveMethodCallEntryPoint extends EntryPoint, ReflectiveMethodCall {
|
||||
class ReflectiveGetMethodCallEntryPoint extends EntryPoint, ReflectiveGetMethodCall {
|
||||
override Method getALiveCallable() {
|
||||
result = this.inferAccessedMethod() and
|
||||
// The `getMethod(...)` call must be used in a live context.
|
||||
@@ -172,8 +172,8 @@ class ReflectiveMethodCallEntryPoint extends EntryPoint, ReflectiveMethodCall {
|
||||
}
|
||||
}
|
||||
|
||||
/** DEPRECATED: Alias for `ReflectiveMethodCallEntryPoint`. */
|
||||
deprecated class ReflectiveMethodAccessEntryPoint = ReflectiveMethodCallEntryPoint;
|
||||
/** DEPRECATED: Alias for `ReflectiveGetMethodCallEntryPoint`. */
|
||||
deprecated class ReflectiveMethodAccessEntryPoint = ReflectiveGetMethodCallEntryPoint;
|
||||
|
||||
/**
|
||||
* Classes that are entry points recognised by annotations.
|
||||
|
||||
@@ -45,8 +45,8 @@ module UnsafeReflectionConfig implements DataFlow::ConfigSig {
|
||||
// Qualifier -> return of Class.getDeclaredConstructors/Methods and similar
|
||||
exists(MethodCall ma |
|
||||
(
|
||||
ma instanceof ReflectiveConstructorsCall or
|
||||
ma instanceof ReflectiveMethodsCall
|
||||
ma instanceof ReflectiveGetConstructorsCall or
|
||||
ma instanceof ReflectiveGetMethodsCall
|
||||
) and
|
||||
ma.getQualifier() = pred.asExpr() and
|
||||
ma = succ.asExpr()
|
||||
|
||||
Reference in New Issue
Block a user