mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Mass-rename MethodAccess -> MethodCall
This commit is contained in:
@@ -19,7 +19,7 @@ private import codeql.typetracking.TypeTracking
|
||||
/**
|
||||
* Gets a viable dispatch target for `ma`. This is the input dispatch relation.
|
||||
*/
|
||||
private Method viableImpl_inp(MethodAccess ma) { result = viableImpl_v2(ma) }
|
||||
private Method viableImpl_inp(MethodCall ma) { result = viableImpl_v2(ma) }
|
||||
|
||||
private Callable dispatchCand(Call c) {
|
||||
c instanceof ConstructorCall and result = c.getCallee().getSourceDeclaration()
|
||||
@@ -99,7 +99,7 @@ private predicate trackedMethodOnType(Method m, SrcRefType t) {
|
||||
* by the type constructed by `cie`. Thus the dispatch from `ma` to `m` will
|
||||
* only be included if `cie` flows to the qualifier of `ma`.
|
||||
*/
|
||||
private predicate dispatchOrigin(ClassInstanceExpr cie, MethodAccess ma, Method m) {
|
||||
private predicate dispatchOrigin(ClassInstanceExpr cie, MethodCall ma, Method m) {
|
||||
m = viableImpl_inp(ma) and
|
||||
not m = ma.getMethod().getSourceDeclaration() and
|
||||
trackedMethodOnType(m, cie.getConstructedType().getSourceDeclaration())
|
||||
@@ -197,10 +197,10 @@ private module TypeTrackingSteps {
|
||||
enum.getAnEnumConstant().getAnAssignedValue() = n1.asExpr() and
|
||||
getValue.getDeclaringType() = enum and
|
||||
getValue.hasName("valueOf") and
|
||||
n2.asExpr().(MethodAccess).getMethod() = getValue
|
||||
n2.asExpr().(MethodCall).getMethod() = getValue
|
||||
)
|
||||
or
|
||||
exists(Variable v, MethodAccess put, MethodAccess get |
|
||||
exists(Variable v, MethodCall put, MethodCall get |
|
||||
put.getArgument(1) = n1.asExpr() and
|
||||
put.getMethod().(MapMethod).hasName("put") and
|
||||
put.getQualifier() = v.getAnAccess() and
|
||||
@@ -209,12 +209,12 @@ private module TypeTrackingSteps {
|
||||
n2.asExpr() = get
|
||||
)
|
||||
or
|
||||
exists(Variable v, MethodAccess add |
|
||||
exists(Variable v, MethodCall add |
|
||||
add.getAnArgument() = n1.asExpr() and
|
||||
add.getMethod().(CollectionMethod).hasName("add") and
|
||||
add.getQualifier() = v.getAnAccess()
|
||||
|
|
||||
exists(MethodAccess get |
|
||||
exists(MethodCall get |
|
||||
get.getQualifier() = v.getAnAccess() and
|
||||
get.getMethod().(CollectionMethod).hasName("get") and
|
||||
n2.asExpr() = get
|
||||
@@ -236,7 +236,7 @@ private module TypeTrackingSteps {
|
||||
enum.getAnEnumConstant().getAnAssignedValue() = n1.asExpr() and
|
||||
getValue.getDeclaringType() = enum and
|
||||
getValue.hasName("values") and
|
||||
n2.asExpr().(MethodAccess).getMethod() = getValue and
|
||||
n2.asExpr().(MethodCall).getMethod() = getValue and
|
||||
f = ContentArray()
|
||||
)
|
||||
or
|
||||
@@ -300,10 +300,10 @@ private module TypeTrackingSteps {
|
||||
private predicate lambdaSource(RelevantNode n) { dispatchOrigin(n.asExpr(), _, _) }
|
||||
|
||||
private predicate lambdaSink(RelevantNode n) {
|
||||
exists(MethodAccess ma | dispatchOrigin(_, ma, _) | n = DataFlow::getInstanceArgument(ma))
|
||||
exists(MethodCall ma | dispatchOrigin(_, ma, _) | n = DataFlow::getInstanceArgument(ma))
|
||||
}
|
||||
|
||||
private signature Method methodDispatchSig(MethodAccess ma);
|
||||
private signature Method methodDispatchSig(MethodCall ma);
|
||||
|
||||
private module TrackLambda<methodDispatchSig/1 lambdaDispatch0> {
|
||||
private Callable dispatch(Call c) {
|
||||
@@ -352,7 +352,7 @@ private module TrackLambda<methodDispatchSig/1 lambdaDispatch0> {
|
||||
|
||||
private predicate edgePlus(PathNode n1, PathNode n2) = fastTC(edges/2)(n1, n2)
|
||||
|
||||
private predicate pairCand(PathNode p1, PathNode p2, Method m, MethodAccess ma) {
|
||||
private predicate pairCand(PathNode p1, PathNode p2, Method m, MethodCall ma) {
|
||||
exists(ClassInstanceExpr cie |
|
||||
dispatchOrigin(cie, ma, m) and
|
||||
p1.getNode() = DataFlow::exprNode(cie) and
|
||||
@@ -367,7 +367,7 @@ private module TrackLambda<methodDispatchSig/1 lambdaDispatch0> {
|
||||
* declares or inherits the tracked method `result` to the qualifier of `ma` such
|
||||
* that `ma` may dispatch to `result`.
|
||||
*/
|
||||
Method lambdaDispatch(MethodAccess ma) {
|
||||
Method lambdaDispatch(MethodCall ma) {
|
||||
exists(PathNode p1, PathNode p2 |
|
||||
(p1 = p2 or edgePlus(p1, p2)) and
|
||||
pairCand(p1, p2, result, ma)
|
||||
@@ -375,30 +375,30 @@ private module TrackLambda<methodDispatchSig/1 lambdaDispatch0> {
|
||||
}
|
||||
}
|
||||
|
||||
private Method noDisp(MethodAccess ma) { none() }
|
||||
private Method noDisp(MethodCall ma) { none() }
|
||||
|
||||
pragma[nomagic]
|
||||
private Method d1(MethodAccess ma) { result = TrackLambda<noDisp/1>::lambdaDispatch(ma) }
|
||||
private Method d1(MethodCall ma) { result = TrackLambda<noDisp/1>::lambdaDispatch(ma) }
|
||||
|
||||
pragma[nomagic]
|
||||
private Method d2(MethodAccess ma) { result = TrackLambda<d1/1>::lambdaDispatch(ma) }
|
||||
private Method d2(MethodCall ma) { result = TrackLambda<d1/1>::lambdaDispatch(ma) }
|
||||
|
||||
pragma[nomagic]
|
||||
private Method d3(MethodAccess ma) { result = TrackLambda<d2/1>::lambdaDispatch(ma) }
|
||||
private Method d3(MethodCall ma) { result = TrackLambda<d2/1>::lambdaDispatch(ma) }
|
||||
|
||||
pragma[nomagic]
|
||||
private Method d4(MethodAccess ma) { result = TrackLambda<d3/1>::lambdaDispatch(ma) }
|
||||
private Method d4(MethodCall ma) { result = TrackLambda<d3/1>::lambdaDispatch(ma) }
|
||||
|
||||
pragma[nomagic]
|
||||
private Method d5(MethodAccess ma) { result = TrackLambda<d4/1>::lambdaDispatch(ma) }
|
||||
private Method d5(MethodCall ma) { result = TrackLambda<d4/1>::lambdaDispatch(ma) }
|
||||
|
||||
pragma[nomagic]
|
||||
private Method d6(MethodAccess ma) { result = TrackLambda<d5/1>::lambdaDispatch(ma) }
|
||||
private Method d6(MethodCall ma) { result = TrackLambda<d5/1>::lambdaDispatch(ma) }
|
||||
|
||||
/**
|
||||
* Gets a viable dispatch target for `ma`. This is the output dispatch relation.
|
||||
*/
|
||||
Method viableImpl_out(MethodAccess ma) {
|
||||
Method viableImpl_out(MethodCall ma) {
|
||||
result = viableImpl_inp(ma) and
|
||||
(result = d6(ma) or not dispatchOrigin(_, ma, result))
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ private import semmle.code.java.dispatch.internal.Unification
|
||||
/**
|
||||
* Gets a viable dispatch target for `ma`. This is the input dispatch relation.
|
||||
*/
|
||||
private Method viableImpl_inp(MethodAccess ma) { result = viableImpl_v3(ma) }
|
||||
private Method viableImpl_inp(MethodCall ma) { result = viableImpl_v3(ma) }
|
||||
|
||||
private Callable dispatchCand(Call c) {
|
||||
c instanceof ConstructorCall and result = c.getCallee().getSourceDeclaration()
|
||||
@@ -193,7 +193,7 @@ private predicate source(RefType t, ObjNode n) {
|
||||
* Holds if `n` is the qualifier of an `Object.toString()` call.
|
||||
*/
|
||||
private predicate sink(ObjNode n) {
|
||||
exists(MethodAccess toString |
|
||||
exists(MethodCall toString |
|
||||
toString.getQualifier() = n.asExpr() and
|
||||
toString.getMethod() instanceof ToStringMethod
|
||||
) and
|
||||
@@ -231,7 +231,7 @@ private predicate objType(ObjNode n, RefType t) {
|
||||
)
|
||||
}
|
||||
|
||||
private VirtualMethodAccess objectToString(ObjNode n) {
|
||||
private VirtualMethodCall objectToString(ObjNode n) {
|
||||
result.getQualifier() = n.asExpr() and sink(n)
|
||||
}
|
||||
|
||||
@@ -239,16 +239,16 @@ private VirtualMethodAccess objectToString(ObjNode n) {
|
||||
* Holds if `ma` is an `Object.toString()` call taking possibly improved type
|
||||
* bounds into account.
|
||||
*/
|
||||
predicate objectToStringCall(VirtualMethodAccess ma) { ma = objectToString(_) }
|
||||
predicate objectToStringCall(VirtualMethodCall ma) { ma = objectToString(_) }
|
||||
|
||||
/**
|
||||
* Holds if the qualifier of the `Object.toString()` call `ma` might have type `t`.
|
||||
*/
|
||||
private predicate objectToStringQualType(MethodAccess ma, RefType t) {
|
||||
private predicate objectToStringQualType(MethodCall ma, RefType t) {
|
||||
exists(ObjNode n | ma = objectToString(n) and objType(n, t))
|
||||
}
|
||||
|
||||
private Method viableImplObjectToString(MethodAccess ma) {
|
||||
private Method viableImplObjectToString(MethodCall ma) {
|
||||
exists(Method def, RefType t |
|
||||
objectToStringQualType(ma, t) and
|
||||
def = ma.getMethod() and
|
||||
@@ -265,7 +265,7 @@ private Method viableImplObjectToString(MethodAccess ma) {
|
||||
* The set of dispatch targets for `Object.toString()` calls are reduced based
|
||||
* on possible data flow from objects of more specific types to the qualifier.
|
||||
*/
|
||||
Method viableImpl_out(MethodAccess ma) {
|
||||
Method viableImpl_out(MethodCall ma) {
|
||||
result = viableImpl_inp(ma) and
|
||||
(
|
||||
result = viableImplObjectToString(ma) or
|
||||
|
||||
@@ -15,7 +15,7 @@ private import semmle.code.java.dispatch.internal.Unification
|
||||
* A conservative analysis that returns a single method - if we can establish
|
||||
* one - that will be the target of the virtual dispatch.
|
||||
*/
|
||||
Method exactVirtualMethod(MethodAccess c) {
|
||||
Method exactVirtualMethod(MethodCall c) {
|
||||
// If there are multiple potential implementations, return nothing.
|
||||
implCount(c, 1) and
|
||||
result = viableImpl(c)
|
||||
@@ -31,7 +31,7 @@ Callable exactCallable(Call c) {
|
||||
c instanceof ConstructorCall and result = c.getCallee()
|
||||
}
|
||||
|
||||
private predicate implCount(MethodAccess m, int c) { strictcount(viableImpl(m)) = c }
|
||||
private predicate implCount(MethodCall m, int c) { strictcount(viableImpl(m)) = c }
|
||||
|
||||
/** Gets a viable implementation of the target of the given `Call`. */
|
||||
Callable viableCallable(Call c) {
|
||||
@@ -44,7 +44,7 @@ Callable viableCallable(Call c) {
|
||||
class VirtCalledSrcMethod extends SrcMethod {
|
||||
pragma[nomagic]
|
||||
VirtCalledSrcMethod() {
|
||||
exists(VirtualMethodAccess ma | ma.getMethod().getSourceDeclaration() = this)
|
||||
exists(VirtualMethodCall ma | ma.getMethod().getSourceDeclaration() = this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ cached
|
||||
private module Dispatch {
|
||||
/** Gets a viable implementation of the method called in the given method access. */
|
||||
cached
|
||||
Method viableImpl(MethodAccess ma) { result = ObjFlow::viableImpl_out(ma) }
|
||||
Method viableImpl(MethodCall ma) { result = ObjFlow::viableImpl_out(ma) }
|
||||
|
||||
/**
|
||||
* Holds if `m` is a viable implementation of the method called in `ma` for
|
||||
@@ -60,7 +60,7 @@ private module Dispatch {
|
||||
* the dispatch type is likely to yield implausible dispatch targets.
|
||||
*/
|
||||
cached
|
||||
predicate lowConfidenceDispatchTarget(MethodAccess ma, Method m) {
|
||||
predicate lowConfidenceDispatchTarget(MethodCall ma, Method m) {
|
||||
m = viableImpl(ma) and lowConfidenceDispatch(ma)
|
||||
}
|
||||
|
||||
@@ -70,13 +70,13 @@ private module Dispatch {
|
||||
* Gets a viable implementation of the method called in the given method access.
|
||||
*/
|
||||
cached
|
||||
Method viableImpl_v3(MethodAccess ma) { result = DispatchFlow::viableImpl_out(ma) }
|
||||
Method viableImpl_v3(MethodCall ma) { result = DispatchFlow::viableImpl_out(ma) }
|
||||
|
||||
/**
|
||||
* Holds if the best type bounds for the qualifier of `ma` are likely to
|
||||
* contain implausible dispatch targets.
|
||||
*/
|
||||
private predicate lowConfidenceDispatch(VirtualMethodAccess ma) {
|
||||
private predicate lowConfidenceDispatch(VirtualMethodCall ma) {
|
||||
exists(RefType t | hasQualifierType(ma, t, false) |
|
||||
lowConfidenceDispatchType(t.getSourceDeclaration())
|
||||
) and
|
||||
@@ -121,7 +121,7 @@ private module Dispatch {
|
||||
* Gets a viable implementation of the method called in the given method access.
|
||||
*/
|
||||
cached
|
||||
Method viableImpl_v2(MethodAccess ma) {
|
||||
Method viableImpl_v2(MethodCall ma) {
|
||||
result = viableImpl_v2_cand(pragma[only_bind_into](ma)) and
|
||||
exists(Method def, RefType t, boolean exact |
|
||||
qualUnionType(pragma[only_bind_into](ma), pragma[only_bind_into](t),
|
||||
@@ -141,7 +141,7 @@ private module Dispatch {
|
||||
not qualUnionType(ma, _, _)
|
||||
}
|
||||
|
||||
private predicate qualUnionType(VirtualMethodAccess ma, RefType t, boolean exact) {
|
||||
private predicate qualUnionType(VirtualMethodCall ma, RefType t, boolean exact) {
|
||||
exprUnionTypeFlow(ma.getQualifier(), t, exact)
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ private module Dispatch {
|
||||
private module Unification_v2 =
|
||||
MkUnification<unificationTargetLeft_v2/1, unificationTargetRight/1>;
|
||||
|
||||
private Method viableImpl_v2_cand(MethodAccess ma) {
|
||||
private Method viableImpl_v2_cand(MethodCall ma) {
|
||||
result = viableImpl_v1(ma) and
|
||||
(
|
||||
exists(Method def, RefType t, boolean exact |
|
||||
@@ -170,7 +170,7 @@ private module Dispatch {
|
||||
)
|
||||
}
|
||||
|
||||
private predicate qualType(VirtualMethodAccess ma, RefType t, boolean exact) {
|
||||
private predicate qualType(VirtualMethodCall ma, RefType t, boolean exact) {
|
||||
exprTypeFlow(ma.getQualifier(), t, exact)
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ private module Dispatch {
|
||||
* Gets a viable implementation of the method called in the given method access.
|
||||
*/
|
||||
cached
|
||||
Method viableImpl_v1(MethodAccess source) {
|
||||
Method viableImpl_v1(MethodCall source) {
|
||||
result = viableImpl_v1_cand(source) and
|
||||
not impossibleDispatchTarget(source, result)
|
||||
}
|
||||
@@ -193,7 +193,7 @@ private module Dispatch {
|
||||
/**
|
||||
* Holds if `source` cannot dispatch to `tgt` due to a negative `instanceof` guard.
|
||||
*/
|
||||
private predicate impossibleDispatchTarget(MethodAccess source, Method tgt) {
|
||||
private predicate impossibleDispatchTarget(MethodCall source, Method tgt) {
|
||||
tgt = viableImpl_v1_cand(source) and
|
||||
exists(InstanceOfExpr ioe, BaseSsaVariable v, Expr q, RefType t |
|
||||
source.getQualifier() = q and
|
||||
@@ -208,9 +208,9 @@ private module Dispatch {
|
||||
/**
|
||||
* Gets a viable implementation of the method called in the given method access.
|
||||
*/
|
||||
private Method viableImpl_v1_cand(MethodAccess source) {
|
||||
private Method viableImpl_v1_cand(MethodCall source) {
|
||||
not result.isAbstract() and
|
||||
if source instanceof VirtualMethodAccess
|
||||
if source instanceof VirtualMethodCall
|
||||
then
|
||||
exists(VirtCalledSrcMethod def, RefType t, boolean exact |
|
||||
source.getMethod().getSourceDeclaration() = def and
|
||||
@@ -242,7 +242,7 @@ private module Dispatch {
|
||||
not e instanceof FunctionalExpr and result = e.getType()
|
||||
}
|
||||
|
||||
private predicate hasQualifierType(VirtualMethodAccess ma, RefType t, boolean exact) {
|
||||
private predicate hasQualifierType(VirtualMethodCall ma, RefType t, boolean exact) {
|
||||
exists(Expr src | src = ma.getQualifier() |
|
||||
// If we have a qualifier, then we take its type.
|
||||
exists(RefType srctype | srctype = getPreciseType(src) |
|
||||
@@ -264,9 +264,9 @@ private module Dispatch {
|
||||
not exists(ma.getQualifier()) and
|
||||
exact = false and
|
||||
(
|
||||
ma.isOwnMethodAccess() and t = ma.getEnclosingCallable().getDeclaringType()
|
||||
ma.isOwnMethodCall() and t = ma.getEnclosingCallable().getDeclaringType()
|
||||
or
|
||||
ma.isEnclosingMethodAccess(t)
|
||||
ma.isEnclosingMethodCall(t)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ private predicate runner(Method m, int n, Method runmethod) {
|
||||
(
|
||||
m.isNative()
|
||||
or
|
||||
exists(Parameter p, MethodAccess ma, int j |
|
||||
exists(Parameter p, MethodCall ma, int j |
|
||||
p = m.getParameter(n) and
|
||||
ma.getEnclosingCallable() = m and
|
||||
runner(pragma[only_bind_into](ma.getMethod().getSourceDeclaration()),
|
||||
@@ -31,7 +31,7 @@ private predicate runner(Method m, int n, Method runmethod) {
|
||||
* through a functional interface. The argument is traced backwards through
|
||||
* casts and variable assignments.
|
||||
*/
|
||||
private Expr getRunnerArgument(MethodAccess ma, Method runmethod) {
|
||||
private Expr getRunnerArgument(MethodCall ma, Method runmethod) {
|
||||
exists(Method runner, int param |
|
||||
runner(runner, param, runmethod) and
|
||||
viableImpl_v2(ma) = runner and
|
||||
@@ -50,7 +50,7 @@ private Expr getRunnerArgument(MethodAccess ma, Method runmethod) {
|
||||
* Gets a method that can be invoked through a functional interface as an
|
||||
* argument to `ma`.
|
||||
*/
|
||||
Method getRunnerTarget(MethodAccess ma) {
|
||||
Method getRunnerTarget(MethodCall ma) {
|
||||
exists(Expr action, Method runmethod | action = getRunnerArgument(ma, runmethod) |
|
||||
action.(FunctionalExpr).asMethod().getSourceDeclaration() = result
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user