mirror of
https://github.com/github/codeql.git
synced 2026-06-13 08:51:20 +02:00
Java/C#/GO: Use instanceof in more places
This commit is contained in:
@@ -58,9 +58,7 @@ abstract class WhitelistedLiveCallable extends CallableEntryPoint { }
|
||||
/**
|
||||
* A `public static void main(String[] args)` method.
|
||||
*/
|
||||
class MainMethodEntry extends CallableEntryPoint {
|
||||
MainMethodEntry() { this instanceof MainMethod }
|
||||
}
|
||||
class MainMethodEntry extends CallableEntryPoint instanceof MainMethod { }
|
||||
|
||||
/**
|
||||
* A method that overrides a library method -- the result is
|
||||
@@ -96,9 +94,7 @@ abstract class ReflectivelyConstructedClass extends EntryPoint, Class {
|
||||
/**
|
||||
* Classes that are deserialized by Jackson are reflectively constructed.
|
||||
*/
|
||||
library class JacksonReflectivelyConstructedClass extends ReflectivelyConstructedClass {
|
||||
JacksonReflectivelyConstructedClass() { this instanceof JacksonDeserializableType }
|
||||
|
||||
library class JacksonReflectivelyConstructedClass extends ReflectivelyConstructedClass instanceof JacksonDeserializableType {
|
||||
override Callable getALiveCallable() {
|
||||
// Constructors may be called by Jackson, if they are a no-arg, they have a suitable annotation,
|
||||
// or inherit a suitable annotation through a mixin.
|
||||
@@ -312,8 +308,7 @@ class FacesAccessibleMethodEntryPoint extends CallableEntryPoint {
|
||||
* A Java Server Faces custom component, that is reflectively constructed by the framework when
|
||||
* used in a view (JSP or facelet).
|
||||
*/
|
||||
class FacesComponentReflectivelyConstructedClass extends ReflectivelyConstructedClass {
|
||||
FacesComponentReflectivelyConstructedClass() { this instanceof FacesComponent }
|
||||
class FacesComponentReflectivelyConstructedClass extends ReflectivelyConstructedClass instanceof FacesComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,8 +395,7 @@ class JavaxManagedBeanReflectivelyConstructed extends ReflectivelyConstructedCla
|
||||
* Classes marked as Java persistence entities can be reflectively constructed when the data is
|
||||
* loaded.
|
||||
*/
|
||||
class PersistentEntityEntryPoint extends ReflectivelyConstructedClass {
|
||||
PersistentEntityEntryPoint() { this instanceof PersistentEntity }
|
||||
class PersistentEntityEntryPoint extends ReflectivelyConstructedClass instanceof PersistentEntity {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,6 +459,5 @@ class ArbitraryXmlEntryPoint extends ReflectivelyConstructedClass {
|
||||
deprecated class ArbitraryXMLEntryPoint = ArbitraryXmlEntryPoint;
|
||||
|
||||
/** A Selenium PageObject, created by a call to PageFactory.initElements(..). */
|
||||
class SeleniumPageObjectEntryPoint extends ReflectivelyConstructedClass {
|
||||
SeleniumPageObjectEntryPoint() { this instanceof SeleniumPageObject }
|
||||
class SeleniumPageObjectEntryPoint extends ReflectivelyConstructedClass instanceof SeleniumPageObject {
|
||||
}
|
||||
|
||||
@@ -50,9 +50,7 @@ class SpringBeanAnnotatedMethod extends CallableEntryPoint {
|
||||
/**
|
||||
* A live entry point within a Spring controller.
|
||||
*/
|
||||
class SpringControllerEntryPoint extends CallableEntryPoint {
|
||||
SpringControllerEntryPoint() { this instanceof SpringControllerMethod }
|
||||
}
|
||||
class SpringControllerEntryPoint extends CallableEntryPoint instanceof SpringControllerMethod { }
|
||||
|
||||
/**
|
||||
* A method that is accessible in a response, because it is part of the returned model,
|
||||
|
||||
@@ -33,23 +33,18 @@ class Struts1ActionEntryPoint extends EntryPoint, Class {
|
||||
/**
|
||||
* A struts 2 action class that is reflectively constructed.
|
||||
*/
|
||||
class Struts2ReflectivelyConstructedAction extends ReflectivelyConstructedClass {
|
||||
Struts2ReflectivelyConstructedAction() { this instanceof Struts2ActionClass }
|
||||
class Struts2ReflectivelyConstructedAction extends ReflectivelyConstructedClass instanceof Struts2ActionClass {
|
||||
}
|
||||
|
||||
/**
|
||||
* A method called on a struts 2 action class when the action is activated.
|
||||
*/
|
||||
class Struts2ActionMethodEntryPoint extends CallableEntryPoint {
|
||||
Struts2ActionMethodEntryPoint() { this instanceof Struts2ActionMethod }
|
||||
}
|
||||
class Struts2ActionMethodEntryPoint extends CallableEntryPoint instanceof Struts2ActionMethod { }
|
||||
|
||||
/**
|
||||
* A method called on a struts 2 action class before an action is activated.
|
||||
*/
|
||||
class Struts2PrepareMethodEntryPoint extends CallableEntryPoint {
|
||||
Struts2PrepareMethodEntryPoint() { this instanceof Struts2PrepareMethod }
|
||||
}
|
||||
class Struts2PrepareMethodEntryPoint extends CallableEntryPoint instanceof Struts2PrepareMethod { }
|
||||
|
||||
/**
|
||||
* A class which is accessible - directly or indirectly - from a struts action.
|
||||
|
||||
@@ -78,13 +78,10 @@ class JUnitCategory extends WhitelistedLiveClass {
|
||||
/**
|
||||
* A listener that will be reflectively constructed by TestNG.
|
||||
*/
|
||||
class TestNGReflectivelyConstructedListener extends ReflectivelyConstructedClass {
|
||||
TestNGReflectivelyConstructedListener() {
|
||||
// Consider any class that implements a TestNG listener interface to be live. Listeners can be
|
||||
// specified on the command line, in `testng.xml` files and in Ant build files, so it is safest
|
||||
// to assume that all such listeners are live.
|
||||
this instanceof TestNGListenerImpl
|
||||
}
|
||||
class TestNGReflectivelyConstructedListener extends ReflectivelyConstructedClass instanceof TestNGListenerImpl {
|
||||
// Consider any class that implements a TestNG listener interface to be live. Listeners can be
|
||||
// specified on the command line, in `testng.xml` files and in Ant build files, so it is safest
|
||||
// to assume that all such listeners are live.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,9 +96,7 @@ class TestNGDataProvidersEntryPoint extends CallableEntryPoint {
|
||||
/**
|
||||
* A `@Factory` TestNG method or constructor which is live.
|
||||
*/
|
||||
class TestNGFactoryEntryPoint extends CallableEntryPoint {
|
||||
TestNGFactoryEntryPoint() { this instanceof TestNGFactoryCallable }
|
||||
}
|
||||
class TestNGFactoryEntryPoint extends CallableEntryPoint instanceof TestNGFactoryCallable { }
|
||||
|
||||
class TestRefectivelyConstructedClass extends ReflectivelyConstructedClass {
|
||||
TestRefectivelyConstructedClass() {
|
||||
@@ -159,6 +154,5 @@ class CucumberConstructedClass extends ReflectivelyConstructedClass {
|
||||
/**
|
||||
* A "step definition" that may be called by Cucumber when executing an acceptance test.
|
||||
*/
|
||||
class CucumberStepDefinitionEntryPoint extends CallableEntryPoint {
|
||||
CucumberStepDefinitionEntryPoint() { this instanceof CucumberStepDefinition }
|
||||
class CucumberStepDefinitionEntryPoint extends CallableEntryPoint instanceof CucumberStepDefinition {
|
||||
}
|
||||
|
||||
@@ -7,17 +7,12 @@ import semmle.code.java.frameworks.Servlets
|
||||
* Any class which extends the `Servlet` interface is intended to be constructed reflectively by a
|
||||
* servlet container.
|
||||
*/
|
||||
class ServletConstructedClass extends ReflectivelyConstructedClass {
|
||||
class ServletConstructedClass extends ReflectivelyConstructedClass instanceof ServletClass {
|
||||
ServletConstructedClass() {
|
||||
this instanceof ServletClass and
|
||||
// If we have seen any `web.xml` files, this servlet will be considered to be live only if it is
|
||||
// referred to as a servlet-class in at least one. If no `web.xml` files are found, we assume
|
||||
// that XML extraction was not enabled, and therefore consider all `Servlet` classes as live.
|
||||
(
|
||||
isWebXmlIncluded()
|
||||
implies
|
||||
exists(WebServletClass servletClass | this = servletClass.getClass())
|
||||
)
|
||||
isWebXmlIncluded() implies exists(WebServletClass servletClass | this = servletClass.getClass())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +107,4 @@ class GwtUiBinderEntryPoint extends CallableEntryPoint {
|
||||
/**
|
||||
* Fields that may be reflectively read or written to by the UiBinder framework.
|
||||
*/
|
||||
class GwtUiBinderReflectivelyReadField extends ReflectivelyReadField {
|
||||
GwtUiBinderReflectivelyReadField() { this instanceof GwtUiField }
|
||||
}
|
||||
class GwtUiBinderReflectivelyReadField extends ReflectivelyReadField instanceof GwtUiField { }
|
||||
|
||||
Reference in New Issue
Block a user