Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: Remove duplicate code. #5273

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions java/ql/src/experimental/Security/CWE/CWE-489/EJBMain.ql
Expand Up @@ -9,13 +9,13 @@

import java
import semmle.code.java.J2EE
import MainLib
import TestLib

/** The `main` method in an Enterprise Java Bean. */
class EnterpriseBeanMainMethod extends Method {
EnterpriseBeanMainMethod() {
this.getDeclaringType() instanceof EnterpriseBean and
isMainMethod(this) and
this instanceof MainMethod and
not isTestMethod(this)
}
}
Expand Down
@@ -1,17 +1,7 @@
/** Definitions related to the main method in a test program. */
/** Definitions related to test methods. */

import java

/** Holds if `m` is the main method of a Java class with the signature `public static void main(String[] args)`. */
predicate isMainMethod(Method m) {
m.hasName("main") and
m.isStatic() and
m.getReturnType() instanceof VoidType and
m.isPublic() and
m.getNumberOfParameters() = 1 and
m.getParameter(0).getType() instanceof Array
}

/**
* Holds if `m` is a test method indicated by:
* a) in a test directory such as `src/test/java`
Expand Down
Expand Up @@ -9,7 +9,7 @@

import java
import semmle.code.java.frameworks.Servlets
import MainLib
import TestLib

/** The java type `javax.servlet.Filter`. */
class ServletFilterClass extends Class {
Expand Down Expand Up @@ -48,7 +48,7 @@ class WebComponentMainMethod extends Method {
.getASupertype+()
.hasQualifiedName("org.springframework.webflow.execution", "Action") // Spring actions
) and
isMainMethod(this) and
this instanceof MainMethod and
not isTestMethod(this)
}
}
Expand Down