Skip to content

Commit 7da6da1

Browse files
authored
Merge pull request github#13852 from github/starcke/automodel-package-filter
Add option to filter automodel queries
2 parents 28863f3 + 131ae1a commit 7da6da1

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

java/ql/src/Telemetry/AutomodelApplicationModeExtractCandidates.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ where
6666
// modeled in a MaD model, then it doesn't belong to any additional sink types, and we don't need to reexamine it.
6767
not CharacteristicsImpl::isSink(endpoint, _, _) and
6868
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input) and
69+
includeAutomodelCandidate(package, type, name, signature) and
6970
// The message is the concatenation of all sink types for which this endpoint is known neither to be a sink nor to be
7071
// a non-sink, and we surface only endpoints that have at least one such sink type.
7172
message =
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/java-queries
4+
extensible: automodelCandidateFilter
5+
data: []

java/ql/src/Telemetry/AutomodelFrameworkModeExtractCandidates.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ where
3030
// modeled in a MaD model, then it doesn't belong to any additional sink types, and we don't need to reexamine it.
3131
not CharacteristicsImpl::isSink(endpoint, _, _) and
3232
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, parameterName) and
33+
includeAutomodelCandidate(package, type, name, signature) and
3334
// The message is the concatenation of all sink types for which this endpoint is known neither to be a sink nor to be
3435
// a non-sink, and we surface only endpoints that have at least one such sink type.
3536
message =

java/ql/src/Telemetry/AutomodelJavaUtil.qll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,24 @@ boolean considerSubtypes(Callable callable) {
6666
then result = false
6767
else result = true
6868
}
69+
70+
/**
71+
* Holds if the given package, type, name and signature is a candidate for automodeling.
72+
*
73+
* This predicate is extensible, so that different endpoints can be selected at runtime.
74+
*/
75+
extensible predicate automodelCandidateFilter(
76+
string package, string type, string name, string signature
77+
);
78+
79+
/**
80+
* Holds if the given package, type, name and signature is a candidate for automodeling.
81+
*
82+
* This relies on an extensible predicate, and if that is not supplied then
83+
* all endpoints are considered candidates.
84+
*/
85+
bindingset[package, type, name, signature]
86+
predicate includeAutomodelCandidate(string package, string type, string name, string signature) {
87+
not automodelCandidateFilter(_, _, _, _) or
88+
automodelCandidateFilter(package, type, name, signature)
89+
}

java/ql/src/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ dependencies:
1212
codeql/util: ${workspace}
1313
dataExtensions:
1414
- Telemetry/ExtractorInformation.yml
15+
- Telemetry/AutomodelCandidateFilter.yml
1516
warnOnImplicitThis: true

0 commit comments

Comments
 (0)