Skip to content

Commit 8f734ad

Browse files
committed
Java: Tighten the criteria for when we disregard generated models.
1 parent 021fd14 commit 8f734ad

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowDispatch.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ private module DispatchImpl {
4545
* The following heuristic is applied for finding the appropriate callable:
4646
* 1. If an exact manual model exists, only dispatch to the summarized callable.
4747
* 2. If a (non exact) manual model exists and/or if the source code is available, dispatch to both/either.
48-
* 3. Only dispatch to a summarized callable (based on a generated model) if neither of the above apply.
48+
* 3. Only dispatch to a summarized callable in case the static call target in not in source.
4949
*/
5050
DataFlowCallable viableCallable(DataFlowCall c) {
5151
exists(Call call | call = c.asCall() |
5252
result.asCallable() = sourceDispatch(call)
5353
or
5454
not (
5555
// Only use summarized callables with generated summaries in case
56-
// we are not able to dispatch to a source declaration.
56+
// the static call target is not in the source code.
5757
// Note that if applyGeneratedModel holds it implies that there doesn't
58-
// exist a manual (exact) model.
59-
exists(Callable callable | callable = sourceDispatch(call) |
60-
callable.fromSource() and not callable.isStub()
58+
// exist a manual model.
59+
exists(Callable staticTarget | staticTarget = call.getCallee().getSourceDeclaration() |
60+
staticTarget.fromSource() and not staticTarget.isStub()
6161
) and
6262
result.asSummarizedCallable().applyGeneratedModel()
6363
) and

0 commit comments

Comments
 (0)