Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18e3763

Browse files
author
Benjamin Muskalla
committed
Expose whether APIs are already supported
1 parent 9b6ae90 commit 18e3763

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

java/ql/src/Telemetry/APIUsage.qll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import java
2+
private import semmle.code.java.dataflow.FlowSteps
3+
private import semmle.code.java.dataflow.ExternalFlow
24

35
private string jarName(CompilationUnit cu) {
46
result = cu.getParentContainer().toString().regexpCapture(".*/(.*\\.jar)/?.*", 1)
@@ -18,3 +20,25 @@ predicate isInterestingAPI(Callable call) {
1820
call.getReturnType() instanceof BoxedType
1921
)
2022
}
23+
24+
// TODO [bm] Fails to detect Collection flow yet (e.g. Map#put)
25+
string supportKind(Callable api) {
26+
if api instanceof TaintPreservingCallable
27+
then result = "taint-preserving"
28+
else
29+
if
30+
summaryModel(api.getCompilationUnit().getPackage().toString(),
31+
api.getDeclaringType().toString(), _, api.getName(), _, _, _, _, _)
32+
then result = "summary"
33+
else
34+
if
35+
sinkModel(api.getCompilationUnit().getPackage().toString(),
36+
api.getDeclaringType().toString(), _, api.getName(), _, _, _, _)
37+
then result = "sink"
38+
else
39+
if
40+
sourceModel(api.getCompilationUnit().getPackage().toString(),
41+
api.getDeclaringType().toString(), _, api.getName(), _, _, _, _)
42+
then result = "source"
43+
else result = "?"
44+
}

java/ql/src/Telemetry/JDKUsage.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ where
1212
cu = call.getCompilationUnit() and
1313
isJavaRuntime(call) and
1414
isInterestingAPI(call)
15-
select cu, call as API, count(Call c | c.getCallee() = call) as calls order by calls desc
15+
select cu, call as API, supportKind(call) as Kind, count(Call c | c.getCallee() = call) as calls
16+
order by calls desc

0 commit comments

Comments
 (0)