Skip to content

Commit b9b4aed

Browse files
committed
Java: Rewrite most telemetry queries to restrict the number of produced results.
1 parent e6e2427 commit b9b4aed

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

java/ql/src/Telemetry/SupportedExternalSinks.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import java
1010
import ExternalApi
1111
import semmle.code.java.GeneratedFiles
1212

13-
from ExternalApi api, int usages
14-
where
13+
private predicate getRelevantUsages(ExternalApi api, int usages) {
1514
not api.isUninteresting() and
1615
api.isSink() and
1716
usages =
1817
strictcount(Call c |
1918
c.getCallee().getSourceDeclaration() = api and
2019
not c.getFile() instanceof GeneratedFile
2120
)
21+
}
22+
23+
from ExternalApi api, int usages
24+
where Results<getRelevantUsages/2>::restrict(api, usages)
2225
select api.getApiName() as apiname, usages order by usages desc

java/ql/src/Telemetry/SupportedExternalSources.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import java
1010
import ExternalApi
1111
import semmle.code.java.GeneratedFiles
1212

13-
from ExternalApi api, int usages
14-
where
13+
private predicate getRelevantUsages(ExternalApi api, int usages) {
1514
not api.isUninteresting() and
1615
api.isSource() and
1716
usages =
1817
strictcount(Call c |
1918
c.getCallee().getSourceDeclaration() = api and
2019
not c.getFile() instanceof GeneratedFile
2120
)
21+
}
22+
23+
from ExternalApi api, int usages
24+
where Results<getRelevantUsages/2>::restrict(api, usages)
2225
select api.getApiName() as apiname, usages order by usages desc

java/ql/src/Telemetry/SupportedExternalTaint.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import java
1010
import ExternalApi
1111
import semmle.code.java.GeneratedFiles
1212

13-
from ExternalApi api, int usages
14-
where
13+
private predicate getRelevantUsages(ExternalApi api, int usages) {
1514
not api.isUninteresting() and
1615
api.hasSummary() and
1716
usages =
1817
strictcount(Call c |
1918
c.getCallee().getSourceDeclaration() = api and
2019
not c.getFile() instanceof GeneratedFile
2120
)
21+
}
22+
23+
from ExternalApi api, int usages
24+
where Results<getRelevantUsages/2>::restrict(api, usages)
2225
select api.getApiName() as apiname, usages order by usages desc

java/ql/src/Telemetry/UnsupportedExternalAPIs.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import java
1010
import ExternalApi
1111
import semmle.code.java.GeneratedFiles
1212

13-
from ExternalApi api, int usages
14-
where
13+
private predicate getRelevantUsages(ExternalApi api, int usages) {
1514
not api.isUninteresting() and
1615
not api.isSupported() and
1716
usages =
1817
strictcount(Call c |
1918
c.getCallee().getSourceDeclaration() = api and
2019
not c.getFile() instanceof GeneratedFile
2120
)
21+
}
22+
23+
from ExternalApi api, int usages
24+
where Results<getRelevantUsages/2>::restrict(api, usages)
2225
select api.getApiName() as apiname, usages order by usages desc

0 commit comments

Comments
 (0)