Skip to content

Commit 3868def

Browse files
author
Stephan Brandauer
committed
use ModelApi to define parameters worth modeling
1 parent 6eefb26 commit 3868def

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

java/ql/src/Telemetry/AutomodelEndpointCharacteristics.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ private import semmle.code.java.security.ExternalAPIs as ExternalAPIs
1212
private import semmle.code.java.Expr as Expr
1313
private import semmle.code.java.security.QueryInjection
1414
private import semmle.code.java.security.RequestForgery
15+
private import semmle.code.java.dataflow.internal.ModelExclusions as ModelExclusions
1516
import AutomodelSharedCharacteristics as SharedCharacteristics
1617
import AutomodelEndpointTypes as AutomodelEndpointTypes
1718

@@ -239,6 +240,18 @@ private class UndocumentedMethodCharacteristic extends CharacteristicsImpl::Unin
239240
}
240241
}
241242

243+
/**
244+
* A characteristic that limits candidates to parameters of methods that are recognized as `ModelApi`, iow., APIs that
245+
* are considered worth modelling.
246+
*/
247+
private class NotAModelApiParameter extends CharacteristicsImpl::UninterestingToModelCharacteristic {
248+
NotAModelApiParameter() { this = "not a model API parameter" }
249+
250+
override predicate appliesToEndpoint(Endpoint e) {
251+
not exists(ModelExclusions::ModelApi api | api.getParameter(_) = e.asParameter())
252+
}
253+
}
254+
242255
/**
243256
* A negative characteristic that filters out non-public methods. Non-public methods are not interesting to include in
244257
* the standard Java modeling, because they cannot be called from outside the package.

0 commit comments

Comments
 (0)