diff --git a/java/ql/src/Telemetry/AutomodelApplicationModeExtractCandidates.ql b/java/ql/src/Telemetry/AutomodelApplicationModeExtractCandidates.ql index 4940b4a741f..49d594dfdef 100644 --- a/java/ql/src/Telemetry/AutomodelApplicationModeExtractCandidates.ql +++ b/java/ql/src/Telemetry/AutomodelApplicationModeExtractCandidates.ql @@ -66,6 +66,7 @@ where // modeled in a MaD model, then it doesn't belong to any additional sink types, and we don't need to reexamine it. not CharacteristicsImpl::isSink(endpoint, _, _) and meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input) and + includeAutomodelCandidate(package, type, name, signature) and // The message is the concatenation of all sink types for which this endpoint is known neither to be a sink nor to be // a non-sink, and we surface only endpoints that have at least one such sink type. message = diff --git a/java/ql/src/Telemetry/AutomodelCandidateFilter.yml b/java/ql/src/Telemetry/AutomodelCandidateFilter.yml new file mode 100644 index 00000000000..52e64d54446 --- /dev/null +++ b/java/ql/src/Telemetry/AutomodelCandidateFilter.yml @@ -0,0 +1,5 @@ +extensions: + - addsTo: + pack: codeql/java-queries + extensible: automodelCandidateFilter + data: [] diff --git a/java/ql/src/Telemetry/AutomodelFrameworkModeExtractCandidates.ql b/java/ql/src/Telemetry/AutomodelFrameworkModeExtractCandidates.ql index e66af08707c..028a27a9bdc 100644 --- a/java/ql/src/Telemetry/AutomodelFrameworkModeExtractCandidates.ql +++ b/java/ql/src/Telemetry/AutomodelFrameworkModeExtractCandidates.ql @@ -30,6 +30,7 @@ where // modeled in a MaD model, then it doesn't belong to any additional sink types, and we don't need to reexamine it. not CharacteristicsImpl::isSink(endpoint, _, _) and meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, parameterName) and + includeAutomodelCandidate(package, type, name, signature) and // The message is the concatenation of all sink types for which this endpoint is known neither to be a sink nor to be // a non-sink, and we surface only endpoints that have at least one such sink type. message = diff --git a/java/ql/src/Telemetry/AutomodelJavaUtil.qll b/java/ql/src/Telemetry/AutomodelJavaUtil.qll index 65be12ce1f9..a224fc291a2 100644 --- a/java/ql/src/Telemetry/AutomodelJavaUtil.qll +++ b/java/ql/src/Telemetry/AutomodelJavaUtil.qll @@ -66,3 +66,24 @@ boolean considerSubtypes(Callable callable) { then result = false else result = true } + +/** + * Holds if the given package, type, name and signature is a candidate for automodeling. + * + * This predicate is extensible, so that different endpoints can be selected at runtime. + */ +extensible predicate automodelCandidateFilter( + string package, string type, string name, string signature +); + +/** + * Holds if the given package, type, name and signature is a candidate for automodeling. + * + * This relies on an extensible predicate, and if that is not supplied then + * all endpoints are considered candidates. + */ +bindingset[package, type, name, signature] +predicate includeAutomodelCandidate(string package, string type, string name, string signature) { + not automodelCandidateFilter(_, _, _, _) or + automodelCandidateFilter(package, type, name, signature) +} diff --git a/java/ql/src/qlpack.yml b/java/ql/src/qlpack.yml index 76f4fcc7797..0e7c892f469 100644 --- a/java/ql/src/qlpack.yml +++ b/java/ql/src/qlpack.yml @@ -12,4 +12,5 @@ dependencies: codeql/util: ${workspace} dataExtensions: - Telemetry/ExtractorInformation.yml + - Telemetry/AutomodelCandidateFilter.yml warnOnImplicitThis: true