@@ -41,31 +41,7 @@ private import semmle.code.java.dataflow.FlowSummary
4141private import semmle.code.java.dataflow.internal.DataFlowPrivate
4242private import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
4343private import semmle.code.java.dataflow.TaintTracking
44-
45- pragma[nomagic]
46- private predicate isTestPackage(Package p) {
47- p.getName()
48- .matches([
49- "org.junit%", "junit.%", "org.mockito%", "org.assertj%",
50- "com.github.tomakehurst.wiremock%", "org.hamcrest%", "org.springframework.test.%",
51- "org.springframework.mock.%", "org.springframework.boot.test.%", "reactor.test%",
52- "org.xmlunit%", "org.testcontainers.%", "org.opentest4j%", "org.mockserver%",
53- "org.powermock%", "org.skyscreamer.jsonassert%", "org.rnorth.visibleassertions",
54- "org.openqa.selenium%", "com.gargoylesoftware.htmlunit%", "org.jboss.arquillian.testng%",
55- "org.testng%"
56- ])
57- }
58-
59- /**
60- * A test library.
61- */
62- private class TestLibrary extends RefType {
63- TestLibrary() { isTestPackage(this.getPackage()) }
64- }
65-
66- private string containerAsJar(Container container) {
67- if container instanceof JarFile then result = container.getBaseName() else result = "rt.jar"
68- }
44+ private import semmle.code.java.dataflow.internal.ModelExclusions
6945
7046/** Holds if the given callable is not worth supporting. */
7147private predicate isUninteresting(Callable c) {
@@ -88,10 +64,18 @@ class ExternalApi extends Callable {
8864 "#" + this.getName() + paramsString(this)
8965 }
9066
67+ private string getJarName() {
68+ result = this.getCompilationUnit().getParentContainer*().(JarFile).getBaseName()
69+ }
70+
9171 /**
9272 * Gets the jar file containing this API. Normalizes the Java Runtime to "rt.jar" despite the presence of modules.
9373 */
94- string jarContainer() { result = containerAsJar(this.getCompilationUnit().getParentContainer*()) }
74+ string jarContainer() {
75+ result = this.getJarName()
76+ or
77+ not exists(this.getJarName()) and result = "rt.jar"
78+ }
9579
9680 /** Gets a node that is an input to a call to this API. */
9781 private DataFlow::Node getAnInput() {
0 commit comments