Move usage count into where clause

This commit is contained in:
Benjamin Muskalla
2021-09-03 11:32:14 +02:00
parent 89ce04dcb9
commit 7d3131ca49
5 changed files with 27 additions and 24 deletions

View File

@@ -10,7 +10,7 @@ private import semmle.code.java.dataflow.ExternalFlow
class ExternalAPI extends Callable {
ExternalAPI() { not this.fromSource() }
/** Holds true if this API is part of a common testing library or framework */
/** Holds if this API is part of a common testing library or framework */
predicate isTestLibrary() { getDeclaringType() instanceof TestLibrary }
/**
@@ -22,7 +22,7 @@ class ExternalAPI extends Callable {
";" + api.getName() + ";" + paramsString(api)
}
/** Holds true if this API is not yet supported by existing CodeQL libraries */
/** Holds if this API is not yet supported by existing CodeQL libraries */
predicate isSupported() { not supportKind(this) = "?" }
/**

View File

@@ -11,12 +11,13 @@ import APIUsage
import ExternalAPI
import semmle.code.java.GeneratedFiles
from ExternalAPI api
from ExternalAPI api, int usages
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
supportKind(api) = "sink" and
usages =
strictcount(Call c |
c.getCallee().getSourceDeclaration() = api and
not c.getFile() instanceof GeneratedFile
)
select api.asCsv(api) as csv, usages order by usages desc

View File

@@ -17,7 +17,7 @@ where
supportKind(api) = "source" and
usages =
strictcount(Call c |
c.getCallee() = api and
c.getCallee().getSourceDeclaration() = api and
not c.getFile() instanceof GeneratedFile
)
select api.asCsv(api) as csv, usages order by usages desc

View File

@@ -11,12 +11,13 @@ import APIUsage
import ExternalAPI
import semmle.code.java.GeneratedFiles
from ExternalAPI api
from ExternalAPI api, int usages
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
supportKind(api) = ["summary", "taint-preserving"] and
usages =
strictcount(Call c |
c.getCallee().getSourceDeclaration() = api and
not c.getFile() instanceof GeneratedFile
)
select api.asCsv(api) as csv, usages order by usages desc

View File

@@ -11,12 +11,13 @@ import APIUsage
import ExternalAPI
import semmle.code.java.GeneratedFiles
from ExternalAPI api
from ExternalAPI api, int usages
where
not api.isTestLibrary() and
not api.isSupported()
select api.asCsv(api) as csv,
strictcount(Call c |
c.getCallee() = api and
not c.getFile() instanceof GeneratedFile
) as Usages order by Usages desc
not api.isSupported() and
usages =
strictcount(Call c |
c.getCallee().getSourceDeclaration() = api and
not c.getFile() instanceof GeneratedFile
)
select api.asCsv(api) as csv, usages order by usages desc