Skip to content

Commit c8b93e0

Browse files
committed
Java: Replace uses of deprecated variableTrack.
1 parent a8eedce commit c8b93e0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ private import DataFlowUtil
44
private import semmle.code.java.dataflow.InstanceAccess
55
private import semmle.code.java.dataflow.FlowSummary
66
private import semmle.code.java.dispatch.VirtualDispatch as VirtualDispatch
7+
private import semmle.code.java.dataflow.TypeFlow
78
private import semmle.code.java.dispatch.internal.Unification
89

910
private module DispatchImpl {
@@ -63,15 +64,21 @@ private module DispatchImpl {
6364
private predicate contextArgHasType(Call ctx, int i, RefType t, boolean exact) {
6465
relevantContext(ctx, i) and
6566
exists(RefType srctype |
66-
exists(Expr arg, Expr src |
67+
exists(Expr arg |
6768
i = -1 and
6869
ctx.getQualifier() = arg
6970
or
7071
ctx.getArgument(i) = arg
7172
|
72-
src = VirtualDispatch::variableTrack(arg) and
73-
srctype = getPreciseType(src) and
74-
if src instanceof ClassInstanceExpr then exact = true else exact = false
73+
exprTypeFlow(arg, srctype, exact)
74+
or
75+
not exprTypeFlow(arg, _, _) and
76+
exprUnionTypeFlow(arg, srctype, exact)
77+
or
78+
not exprTypeFlow(arg, _, _) and
79+
not exprUnionTypeFlow(arg, _, _) and
80+
srctype = getPreciseType(arg) and
81+
if arg instanceof ClassInstanceExpr then exact = true else exact = false
7582
)
7683
or
7784
exists(Node arg |

java/ql/src/Security/CWE/CWE-327/MaybeBrokenCryptoAlgorithm.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ predicate objectToString(MethodAccess ma) {
3838
exists(ToStringMethod m |
3939
m = ma.getMethod() and
4040
m.getDeclaringType() instanceof TypeObject and
41-
variableTrack(ma.getQualifier()).getType().getErasure() instanceof TypeObject
41+
exprNode(ma.getQualifier()).getTypeBound().getErasure() instanceof TypeObject
4242
)
4343
}
4444

0 commit comments

Comments
 (0)