Skip to content

Commit 87ef540

Browse files
author
Benjamin Muskalla
committed
Split out queries showing supported APIs
1 parent 89f4a35 commit 87ef540

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

java/ql/src/Telemetry/APIUsage.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ private predicate sink(Callable api) {
3131

3232
private predicate source(Callable api) {
3333
sourceModel(packageName(api), typeName(api), _, api.getName(), _, _, _, _)
34+
or
35+
exists(Call call, DataFlow::Node arg |
36+
call.getCallee() = api and
37+
[call.getAnArgument(), call.getQualifier()] = arg.asExpr() and
38+
arg instanceof RemoteFlowSource
39+
)
3440
}
3541

3642
private string packageName(Callable api) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @name Supported sinks in external libraries
3+
* @description A list of 3rd party APIs detected as sinks. Excludes test and generated code.
4+
* @id java/telemetry/supported-external-api-sinks
5+
* @kind metric
6+
* @metricType callable
7+
*/
8+
9+
import java
10+
import APIUsage
11+
import ExternalAPI
12+
import semmle.code.java.GeneratedFiles
13+
14+
from ExternalAPI api
15+
where
16+
not api.isTestLibrary() and
17+
supportKind(api) = "sink"
18+
select api.asCSV(api) as csv,
19+
strictcount(Call c |
20+
c.getCallee() = api and
21+
not c.getFile() instanceof GeneratedFile
22+
) as Usages order by Usages desc
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @name Supported sources in external libraries
3+
* @description A list of 3rd party APIs detected as sources. Excludes test and generated code.
4+
* @id java/telemetry/supported-external-api-sources
5+
* @kind metric
6+
* @metricType callable
7+
*/
8+
9+
import java
10+
import APIUsage
11+
import ExternalAPI
12+
import semmle.code.java.GeneratedFiles
13+
14+
from ExternalAPI api
15+
where
16+
not api.isTestLibrary() and
17+
supportKind(api) = "source"
18+
select api.asCSV(api) as csv,
19+
strictcount(Call c |
20+
c.getCallee() = api and
21+
not c.getFile() instanceof GeneratedFile
22+
) as Usages order by Usages desc
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @name Supported sinks in external libraries
3+
* @description A list of 3rd party APIs detected as sinks. Excludes test and generated code.
4+
* @id java/telemetry/supported-external-api-taint
5+
* @kind metric
6+
* @metricType callable
7+
*/
8+
9+
import java
10+
import APIUsage
11+
import ExternalAPI
12+
import semmle.code.java.GeneratedFiles
13+
14+
from ExternalAPI api
15+
where
16+
not api.isTestLibrary() and
17+
supportKind(api) = ["summary", "taint-preserving"]
18+
select api.asCSV(api) as csv,
19+
strictcount(Call c |
20+
c.getCallee() = api and
21+
not c.getFile() instanceof GeneratedFile
22+
) as Usages order by Usages desc

java/ql/src/Telemetry/ExternalAPIUsages.ql renamed to java/ql/src/Telemetry/UnsupportedExternalAPIs.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @name Usage of APIs coming from external libraries
33
* @description A list of 3rd party APIs used in the codebase. Excludes test and generated code.
4-
* @id java/telemetry/external-api
4+
* @id java/telemetry/unsupported-external-api
55
* @kind metric
66
* @metricType callable
77
*/

0 commit comments

Comments
 (0)