Skip to content

Commit 9b8d7df

Browse files
committed
Add option to filter automodel queries by package.
1 parent 89aa86a commit 9b8d7df

File tree

5 files changed

+27
-0
lines changed

5 files changed

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

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)