Skip to content

Commit 587ee53

Browse files
committed
Java: Fix ExternalApi.jarContainer().
1 parent e925365 commit 587ee53

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

java/ql/src/Telemetry/ExternalApi.qll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ private import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummary
1010
private import semmle.code.java.dataflow.TaintTracking
1111
private import semmle.code.java.dataflow.internal.ModelExclusions
1212

13-
private string containerAsJar(Container container) {
14-
if container instanceof JarFile then result = container.getBaseName() else result = "rt.jar"
15-
}
16-
1713
/** Holds if the given callable is not worth supporting. */
1814
private predicate isUninteresting(Callable c) {
1915
c.getDeclaringType() instanceof TestLibrary or
@@ -35,10 +31,18 @@ class ExternalApi extends Callable {
3531
"#" + this.getName() + paramsString(this)
3632
}
3733

34+
private string getJarName() {
35+
result = this.getCompilationUnit().getParentContainer*().(JarFile).getBaseName()
36+
}
37+
3838
/**
3939
* Gets the jar file containing this API. Normalizes the Java Runtime to "rt.jar" despite the presence of modules.
4040
*/
41-
string jarContainer() { result = containerAsJar(this.getCompilationUnit().getParentContainer*()) }
41+
string jarContainer() {
42+
result = this.getJarName()
43+
or
44+
not exists(this.getJarName()) and result = "rt.jar"
45+
}
4246

4347
/** Gets a node that is an input to a call to this API. */
4448
private DataFlow::Node getAnInput() {

0 commit comments

Comments
 (0)