Skip to content

Commit 26d4269

Browse files
author
Benjamin Muskalla
committed
Use FlowSources for coverage tracking
1 parent c48586f commit 26d4269

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

java/ql/src/Telemetry/APIUsage.qll

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
import java
2-
private import semmle.code.java.dataflow.FlowSteps
3-
private import semmle.code.java.dataflow.ExternalFlow
4-
private import semmle.code.java.dataflow.FlowSummary
5-
private import semmle.code.java.dataflow.DataFlow
6-
private import semmle.code.java.dataflow.TaintTracking
72
private import semmle.code.java.dataflow.FlowSources
83

94
string supportKind(Callable api) {
@@ -22,27 +17,21 @@ string supportKind(Callable api) {
2217
}
2318

2419
predicate summaryCall(Callable api) {
25-
api instanceof SummarizedCallable
26-
or
27-
exists(Call call, DataFlow::Node arg |
28-
call.getCallee() = api and
29-
[call.getAnArgument(), call.getQualifier()] = arg.asExpr() and
30-
TaintTracking::localAdditionalTaintStep(arg, _)
31-
)
20+
summaryModel(packageName(api), typeName(api), _, api.getName(), _, _, _, _, _)
3221
}
3322

3423
predicate sink(Callable api) {
35-
exists(Call call, DataFlow::Node arg |
36-
call.getCallee() = api and
37-
[call.getAnArgument(), call.getQualifier()] = arg.asExpr() and
38-
sinkNode(arg, _)
39-
)
24+
sinkModel(packageName(api), typeName(api), _, api.getName(), _, _, _, _)
4025
}
4126

4227
predicate source(Callable api) {
43-
exists(Call call, DataFlow::Node arg |
44-
call.getCallee() = api and
45-
[call.getAnArgument(), call.getQualifier()] = arg.asExpr() and
46-
arg instanceof RemoteFlowSource
47-
)
28+
sourceModel(packageName(api), typeName(api), _, api.getName(), _, _, _, _)
29+
}
30+
31+
private string packageName(Callable api) {
32+
result = api.getCompilationUnit().getPackage().toString()
33+
}
34+
35+
private string typeName(Callable api) {
36+
result = api.getDeclaringType().getAnAncestor().getSourceDeclaration().toString()
4837
}

0 commit comments

Comments
 (0)