Address review comments

This commit is contained in:
Tom Hvitved
2021-06-04 14:29:53 +02:00
parent cc02c95092
commit 42202402a4
5 changed files with 15 additions and 17 deletions

View File

@@ -712,8 +712,8 @@ module Private {
exists(SourceOrSinkElement e |
sourceElement(e, output, kind) and
if outputNeedsReference(specLast(output))
then viableCallable(ref.asCall()) = any(InterpretNode n | n.asElement() = e).asCallable()
else ref.asElement() = e
then e = ref.getCallTarget()
else e = ref.asElement()
)
}
@@ -721,8 +721,8 @@ module Private {
exists(SourceOrSinkElement e |
sinkElement(e, input, kind) and
if inputNeedsReference(specLast(input))
then viableCallable(ref.asCall()) = any(InterpretNode n | n.asElement() = e).asCallable()
else ref.asElement() = e
then e = ref.getCallTarget()
else e = ref.asElement()
)
}

View File

@@ -136,6 +136,9 @@ class InterpretNode extends TInterpretNode {
/** Gets the callable that this node corresponds to, if any. */
DataFlowCallable asCallable() { result = this.asElement() }
/** Gets the target of this call, if any. */
Callable getCallTarget() { result = this.asCall().getARuntimeTarget() }
/** Gets a textual representation of this node. */
string toString() {
result = this.asElement().toString()

View File

@@ -4,21 +4,13 @@ private import DataFlowUtil
private import semmle.code.java.dataflow.InstanceAccess
private import semmle.code.java.dataflow.FlowSummary
private import semmle.code.java.dispatch.VirtualDispatch as VirtualDispatch
private import semmle.code.java.dataflow.internal.FlowSummaryImplSpecific
private module DispatchImpl {
/** Gets a viable implementation of the target of the given `Call`. */
Callable viableCallable(Call c) {
result = VirtualDispatch::viableCallable(c)
or
result = c.getCallee().getSourceDeclaration() and
(
result instanceof SummarizedCallable
or
sourceElement(result, _, _)
or
sinkElement(result, _, _)
)
result.(SummarizedCallable) = c.getCallee().getSourceDeclaration()
}
/**

View File

@@ -712,8 +712,8 @@ module Private {
exists(SourceOrSinkElement e |
sourceElement(e, output, kind) and
if outputNeedsReference(specLast(output))
then viableCallable(ref.asCall()) = any(InterpretNode n | n.asElement() = e).asCallable()
else ref.asElement() = e
then e = ref.getCallTarget()
else e = ref.asElement()
)
}
@@ -721,8 +721,8 @@ module Private {
exists(SourceOrSinkElement e |
sinkElement(e, input, kind) and
if inputNeedsReference(specLast(input))
then viableCallable(ref.asCall()) = any(InterpretNode n | n.asElement() = e).asCallable()
else ref.asElement() = e
then e = ref.getCallTarget()
else e = ref.asElement()
)
}

View File

@@ -125,6 +125,9 @@ class InterpretNode extends TInterpretNode {
/** Gets the callable that this node corresponds to, if any. */
DataFlowCallable asCallable() { result = this.asElement() }
/** Gets the target of this call, if any. */
Callable getCallTarget() { result = this.asCall().getCallee().getSourceDeclaration() }
/** Gets a textual representation of this node. */
string toString() {
result = this.asElement().toString()