mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Java: add hasApiName predicate
This commit is contained in:
@@ -61,24 +61,18 @@ predicate topJdkApiName(string apiName) {
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information about the given API in the form expected by the
|
||||
* MaD modeling framework.
|
||||
*/
|
||||
string getApiName(Callable api) {
|
||||
result =
|
||||
api.getDeclaringType().getPackage() + "." + api.getDeclaringType().getSourceDeclaration() + "#" +
|
||||
api.getName() + paramsString(api)
|
||||
/** Holds if `c` has the MaD-formatted name `apiName`. */
|
||||
predicate hasApiName(Callable c, string apiName) {
|
||||
apiName =
|
||||
c.getDeclaringType().getPackage() + "." + c.getDeclaringType().getSourceDeclaration() + "#" +
|
||||
c.getName() + paramsString(c)
|
||||
}
|
||||
|
||||
/** Holds if the given API has a `Callable`. */
|
||||
predicate hasCallable(string apiName) { exists(Callable callable | apiName = getApiName(callable)) }
|
||||
|
||||
/** A top JDK API. */
|
||||
class TopJdkApi extends SummarizedCallableBase {
|
||||
TopJdkApi() {
|
||||
exists(string apiName |
|
||||
apiName = getApiName(this.asCallable()) and
|
||||
hasApiName(this.asCallable(), apiName) and
|
||||
topJdkApiName(apiName)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ from string apiName, string message
|
||||
where
|
||||
// top jdk api names for which there is no callable
|
||||
topJdkApiName(apiName) and
|
||||
not hasCallable(apiName) and
|
||||
not exists(Callable c | hasApiName(c, apiName)) and
|
||||
message = "no callable"
|
||||
or
|
||||
// top jdk api names for which there isn't a manual model
|
||||
exists(TopJdkApi topApi |
|
||||
not topApi.hasManualMadModel() and
|
||||
apiName = getApiName(topApi.asCallable()) and
|
||||
hasApiName(topApi.asCallable(), apiName) and
|
||||
message = "no manual model"
|
||||
)
|
||||
select apiName, message order by apiName
|
||||
|
||||
Reference in New Issue
Block a user