Split out queries showing supported APIs

This commit is contained in:
Benjamin Muskalla
2021-08-16 16:38:32 +02:00
parent 89f4a35273
commit 87ef540b52
5 changed files with 73 additions and 1 deletions

View File

@@ -31,6 +31,12 @@ private predicate sink(Callable api) {
private predicate source(Callable api) {
sourceModel(packageName(api), typeName(api), _, api.getName(), _, _, _, _)
or
exists(Call call, DataFlow::Node arg |
call.getCallee() = api and
[call.getAnArgument(), call.getQualifier()] = arg.asExpr() and
arg instanceof RemoteFlowSource
)
}
private string packageName(Callable api) {

View File

@@ -0,0 +1,22 @@
/**
* @name Supported sinks in external libraries
* @description A list of 3rd party APIs detected as sinks. Excludes test and generated code.
* @id java/telemetry/supported-external-api-sinks
* @kind metric
* @metricType callable
*/
import java
import APIUsage
import ExternalAPI
import semmle.code.java.GeneratedFiles
from ExternalAPI api
where
not api.isTestLibrary() and
supportKind(api) = "sink"
select api.asCSV(api) as csv,
strictcount(Call c |
c.getCallee() = api and
not c.getFile() instanceof GeneratedFile
) as Usages order by Usages desc

View File

@@ -0,0 +1,22 @@
/**
* @name Supported sources in external libraries
* @description A list of 3rd party APIs detected as sources. Excludes test and generated code.
* @id java/telemetry/supported-external-api-sources
* @kind metric
* @metricType callable
*/
import java
import APIUsage
import ExternalAPI
import semmle.code.java.GeneratedFiles
from ExternalAPI api
where
not api.isTestLibrary() and
supportKind(api) = "source"
select api.asCSV(api) as csv,
strictcount(Call c |
c.getCallee() = api and
not c.getFile() instanceof GeneratedFile
) as Usages order by Usages desc

View File

@@ -0,0 +1,22 @@
/**
* @name Supported sinks in external libraries
* @description A list of 3rd party APIs detected as sinks. Excludes test and generated code.
* @id java/telemetry/supported-external-api-taint
* @kind metric
* @metricType callable
*/
import java
import APIUsage
import ExternalAPI
import semmle.code.java.GeneratedFiles
from ExternalAPI api
where
not api.isTestLibrary() and
supportKind(api) = ["summary", "taint-preserving"]
select api.asCSV(api) as csv,
strictcount(Call c |
c.getCallee() = api and
not c.getFile() instanceof GeneratedFile
) as Usages order by Usages desc

View File

@@ -1,7 +1,7 @@
/**
* @name Usage of APIs coming from external libraries
* @description A list of 3rd party APIs used in the codebase. Excludes test and generated code.
* @id java/telemetry/external-api
* @id java/telemetry/unsupported-external-api
* @kind metric
* @metricType callable
*/