mirror of
https://github.com/github/codeql.git
synced 2026-04-22 15:25:18 +02:00
Java: Replace the MaD Object.clone() models with a non-aliasing value step.
This commit is contained in:
@@ -91,9 +91,6 @@ extensions:
|
||||
- ["java.lang", "Iterable", True, "iterator", "()", "", "Argument[this].Element", "ReturnValue.Element", "value", "manual"]
|
||||
- ["java.lang", "Iterable", True, "spliterator", "()", "", "Argument[this].Element", "ReturnValue.Element", "value", "manual"]
|
||||
- ["java.lang", "NullPointerException", False, "NullPointerException", "(String)", "", "Argument[0]", "Argument[this].SyntheticField[java.lang.Throwable.message]", "value", "manual"]
|
||||
- ["java.lang", "Object", True, "clone", "", "", "Argument[this].Element", "ReturnValue.Element", "value", "manual"]
|
||||
- ["java.lang", "Object", True, "clone", "", "", "Argument[this].MapKey", "ReturnValue.MapKey", "value", "manual"]
|
||||
- ["java.lang", "Object", True, "clone", "", "", "Argument[this].MapValue", "ReturnValue.MapValue", "value", "manual"]
|
||||
- ["java.lang", "RuntimeException", False, "RuntimeException", "(String)", "", "Argument[0]", "Argument[this].SyntheticField[java.lang.Throwable.message]", "value", "manual"]
|
||||
- ["java.lang", "RuntimeException", False, "RuntimeException", "(String,Throwable)", "", "Argument[0]", "Argument[this].SyntheticField[java.lang.Throwable.message]", "value", "manual"]
|
||||
- ["java.lang", "RuntimeException", False, "RuntimeException", "(String,Throwable)", "", "Argument[1]", "Argument[this].SyntheticField[java.lang.Throwable.cause]", "value", "manual"]
|
||||
|
||||
@@ -22,6 +22,8 @@ module JavaDataFlow implements InputSig<Location> {
|
||||
|
||||
predicate getSecondLevelScope = Private::getSecondLevelScope/1;
|
||||
|
||||
predicate validParameterAliasStep = Private::validParameterAliasStep/2;
|
||||
|
||||
predicate mayBenefitFromCallContext = Private::mayBenefitFromCallContext/1;
|
||||
|
||||
predicate viableImplInCallContext = Private::viableImplInCallContext/2;
|
||||
|
||||
@@ -400,6 +400,18 @@ class CastNode extends ExprNode {
|
||||
}
|
||||
}
|
||||
|
||||
/** Holds if `n1` is the qualifier of a call to `clone()` and `n2` is the result. */
|
||||
predicate cloneStep(Node n1, Node n2) {
|
||||
exists(MethodCall mc |
|
||||
mc.getMethod() instanceof CloneMethod and
|
||||
n1 = getInstanceArgument(mc) and
|
||||
n2.asExpr() = mc
|
||||
)
|
||||
}
|
||||
|
||||
bindingset[node1, node2]
|
||||
predicate validParameterAliasStep(Node node1, Node node2) { not cloneStep(node1, node2) }
|
||||
|
||||
private newtype TDataFlowCallable =
|
||||
TSrcCallable(Callable c) or
|
||||
TSummarizedCallable(SummarizedCallable c) or
|
||||
|
||||
@@ -258,6 +258,8 @@ private predicate simpleLocalFlowStep0(Node node1, Node node2, string model) {
|
||||
model = "ValuePreservingMethod"
|
||||
)
|
||||
or
|
||||
cloneStep(node1, node2) and model = "CloneStep"
|
||||
or
|
||||
FlowSummaryImpl::Private::Steps::summaryLocalStep(node1.(FlowSummaryNode).getSummaryNode(),
|
||||
node2.(FlowSummaryNode).getSummaryNode(), true, model)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user