Skip to content

Commit 86888b8

Browse files
committed
Java: Re-factor isSupported for the telemetry queries.
1 parent f594411 commit 86888b8

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

java/ql/src/Telemetry/ExternalApi.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ private import semmle.code.java.dataflow.ExternalFlow
66
private import semmle.code.java.dataflow.FlowSources
77
private import semmle.code.java.dataflow.FlowSummary
88
private import semmle.code.java.dataflow.internal.DataFlowPrivate
9+
private import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
910
private import semmle.code.java.dataflow.TaintTracking
1011

1112
pragma[nomagic]
@@ -91,8 +92,14 @@ class ExternalApi extends Callable {
9192
pragma[nomagic]
9293
predicate isSink() { sinkNode(this.getAnInput(), _) }
9394

95+
/** Holds if this API is a known neutral. */
96+
pragma[nomagic]
97+
predicate isNeutral() { this = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable() }
98+
9499
/** Holds if this API is supported by existing CodeQL libraries, that is, it is either a recognized source or sink or has a flow summary. */
95-
predicate isSupported() { this.hasSummary() or this.isSource() or this.isSink() }
100+
predicate isSupported() {
101+
this.hasSummary() or this.isSource() or this.isSink() or this.isNeutral()
102+
}
96103
}
97104

98105
/** DEPRECATED: Alias for ExternalApi */

java/ql/src/Telemetry/SupportedExternalApis.ql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
*/
88

99
import java
10-
import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
1110
import ExternalApi
1211

13-
private predicate relevant(ExternalApi api) {
14-
api.isSupported() or
15-
api = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable()
16-
}
12+
private predicate relevant(ExternalApi api) { api.isSupported() }
1713

1814
from string apiName, int usages
1915
where Results<relevant/1>::restrict(apiName, usages)

java/ql/src/Telemetry/UnsupportedExternalAPIs.ql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
*/
88

99
import java
10-
import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
1110
import ExternalApi
1211

13-
private predicate relevant(ExternalApi api) {
14-
not api.isSupported() and
15-
not api = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable()
16-
}
12+
private predicate relevant(ExternalApi api) { not api.isSupported() }
1713

1814
from string apiName, int usages
1915
where Results<relevant/1>::restrict(apiName, usages)

0 commit comments

Comments
 (0)