mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Expose whether APIs are already supported
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import java
|
||||
private import semmle.code.java.dataflow.FlowSteps
|
||||
private import semmle.code.java.dataflow.ExternalFlow
|
||||
|
||||
private string jarName(CompilationUnit cu) {
|
||||
result = cu.getParentContainer().toString().regexpCapture(".*/(.*\\.jar)/?.*", 1)
|
||||
@@ -18,3 +20,25 @@ predicate isInterestingAPI(Callable call) {
|
||||
call.getReturnType() instanceof BoxedType
|
||||
)
|
||||
}
|
||||
|
||||
// TODO [bm] Fails to detect Collection flow yet (e.g. Map#put)
|
||||
string supportKind(Callable api) {
|
||||
if api instanceof TaintPreservingCallable
|
||||
then result = "taint-preserving"
|
||||
else
|
||||
if
|
||||
summaryModel(api.getCompilationUnit().getPackage().toString(),
|
||||
api.getDeclaringType().toString(), _, api.getName(), _, _, _, _, _)
|
||||
then result = "summary"
|
||||
else
|
||||
if
|
||||
sinkModel(api.getCompilationUnit().getPackage().toString(),
|
||||
api.getDeclaringType().toString(), _, api.getName(), _, _, _, _)
|
||||
then result = "sink"
|
||||
else
|
||||
if
|
||||
sourceModel(api.getCompilationUnit().getPackage().toString(),
|
||||
api.getDeclaringType().toString(), _, api.getName(), _, _, _, _)
|
||||
then result = "source"
|
||||
else result = "?"
|
||||
}
|
||||
|
||||
@@ -12,4 +12,5 @@ where
|
||||
cu = call.getCompilationUnit() and
|
||||
isJavaRuntime(call) and
|
||||
isInterestingAPI(call)
|
||||
select cu, call as API, count(Call c | c.getCallee() = call) as calls order by calls desc
|
||||
select cu, call as API, supportKind(call) as Kind, count(Call c | c.getCallee() = call) as calls
|
||||
order by calls desc
|
||||
|
||||
Reference in New Issue
Block a user