Skip to content

Commit 527dafa

Browse files
committed
Java: Improve dispatch through TypeFlow of effectively private calls.
1 parent 5cf7112 commit 527dafa

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

java/ql/lib/semmle/code/java/dataflow/TypeFlow.qll

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,24 @@ private module Input implements TypeFlowInput<Location> {
6363

6464
class Type = RefType;
6565

66+
private SrcCallable viableCallable_v1(Call c) {
67+
result = viableImpl_v1(c)
68+
or
69+
c instanceof ConstructorCall and result = c.getCallee().getSourceDeclaration()
70+
}
71+
6672
/**
67-
* Holds if `arg` is an argument for the parameter `p` in a private callable.
73+
* Holds if `arg` is an argument for the parameter `p` in a sufficiently
74+
* private callable that the closed-world assumption applies.
6875
*/
6976
private predicate privateParamArg(Parameter p, Argument arg) {
70-
p.getAnArgument() = arg and
71-
p.getCallable().isPrivate()
77+
exists(SrcCallable c, Call call |
78+
c = p.getCallable() and
79+
not c.isImplicitlyPublic() and
80+
not p.isVarargs() and
81+
c = viableCallable_v1(call) and
82+
call.getArgument(pragma[only_bind_into](pragma[only_bind_out](p.getPosition()))) = arg
83+
)
7284
}
7385

7486
/**

0 commit comments

Comments
 (0)