Skip to content

Commit 8aba0b0

Browse files
author
Benjamin Muskalla
committed
Add QLDoc for all shared libraries
1 parent 26ffe6c commit 8aba0b0

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

java/ql/src/Telemetry/APIUsage.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/** Provides classes and predicates related to support coverage of external libraries. */
2+
13
import java
24
private import semmle.code.java.dataflow.FlowSources
35

6+
/**
7+
* Gets the coverage support for the given `Callable`. If the `Callable` is not supported, returns "?".
8+
*/
49
string supportKind(Callable api) {
510
if api instanceof TaintPreservingCallable
611
then result = "taint-preserving"
@@ -16,15 +21,15 @@ string supportKind(Callable api) {
1621
else result = "?"
1722
}
1823

19-
predicate summaryCall(Callable api) {
24+
private predicate summaryCall(Callable api) {
2025
summaryModel(packageName(api), typeName(api), _, api.getName(), _, _, _, _, _)
2126
}
2227

23-
predicate sink(Callable api) {
28+
private predicate sink(Callable api) {
2429
sinkModel(packageName(api), typeName(api), _, api.getName(), _, _, _, _)
2530
}
2631

27-
predicate source(Callable api) {
32+
private predicate source(Callable api) {
2833
sourceModel(packageName(api), typeName(api), _, api.getName(), _, _, _, _)
2934
}
3035

java/ql/src/Telemetry/ExternalAPI.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
/** Provides classes and predicates related to handling APIs from external libraries. */
2+
13
private import java
24
private import APIUsage
35
private import semmle.code.java.dataflow.ExternalFlow
46

7+
/**
8+
* An external API from either the Java Standard Library or a 3rd party library.
9+
*/
510
class ExternalAPI extends Callable {
611
ExternalAPI() { not this.fromSource() }
712

13+
/** Holds true if this API is part of a common testing library or framework */
814
predicate isTestLibrary() { getDeclaringType() instanceof TestLibrary }
915

16+
/** Holds true if this API has inputs or outputs that are interesting to support by CodeQL. */
1017
predicate isInteresting() {
1118
getNumberOfParameters() > 0 and
1219
exists(Type retType | retType = getReturnType() |
@@ -16,14 +23,21 @@ class ExternalAPI extends Callable {
1623
)
1724
}
1825

26+
/**
27+
* Gets information about the external API in the form expected by the CSV modeling framework.
28+
*/
1929
string asCSV(ExternalAPI api) {
2030
result =
2131
api.getDeclaringType().getPackage() + ";?;" + api.getDeclaringType().getSourceDeclaration() +
2232
";" + api.getName() + ";" + paramsString(api)
2333
}
2434

35+
/** Holds true if this API is not yet supported by existing CodeQL libraries */
2536
predicate isSupported() { not supportKind(this) = "?" }
2637

38+
/**
39+
* Gets the jar file containing this API. Normalizes the Java Runtime to "rt.jar" despite the presence of modules.
40+
*/
2741
string jarContainer() {
2842
result = containerAsJar(any(ExternalAPI api).getCompilationUnit().getParentContainer*())
2943
}

0 commit comments

Comments
 (0)