diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll index dd8d8ec073f4..7a44432965cb 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll @@ -11,6 +11,7 @@ private import Node0ToString private import ModelUtil private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs as IO private import semmle.code.cpp.models.interfaces.DataFlow as DF +private import semmle.code.cpp.dataflow.ExternalFlow as External cached private module Cached { @@ -1060,16 +1061,6 @@ class DataFlowCallable extends TDataFlowCallable { result = this.asSummarizedCallable() or // SummarizedCallable = Function (in CPP) result = this.asSourceCallable() } - - /** Gets a best-effort total ordering. */ - int totalorder() { - this = - rank[result](DataFlowCallable c, string file, int startline, int startcolumn | - c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _) - | - c order by file, startline, startcolumn - ) - } } /** @@ -1276,15 +1267,6 @@ module IsUnreachableInCall { string toString() { result = "NodeRegion" } predicate contains(Node n) { this = n.getBasicBlock() } - - int totalOrder() { - this = - rank[result](IRBlock b, int startline, int startcolumn | - b.getLocation().hasLocationInfo(_, startline, startcolumn, _, _) - | - b order by startline, startcolumn - ) - } } predicate isUnreachableInCall(NodeRegion block, DataFlowCall call) { @@ -1369,9 +1351,9 @@ predicate lambdaCall(DataFlowCall call, LambdaCallKind kind, Node receiver) { /** Extra data-flow steps needed for lambda flow analysis. */ predicate additionalLambdaFlowStep(Node nodeFrom, Node nodeTo, boolean preservesValue) { none() } -predicate knownSourceModel(Node source, string model) { none() } +predicate knownSourceModel(Node source, string model) { External::sourceNode(source, _, model) } -predicate knownSinkModel(Node sink, string model) { none() } +predicate knownSinkModel(Node sink, string model) { External::sinkNode(sink, _, model) } /** * Holds if flow is allowed to pass from parameter `p` and back to itself as a diff --git a/go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll b/go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll index 369786498f7e..fd9c5e272061 100644 --- a/go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll +++ b/go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll @@ -318,16 +318,6 @@ class DataFlowCallable extends TDataFlowCallable { result = this.asFileScope().getLocation() or result = getCallableLocation(this.asSummarizedCallable()) } - - /** Gets a best-effort total ordering. */ - int totalorder() { - this = - rank[result](DataFlowCallable c, string file, int startline, int startcolumn | - c.hasLocationInfo(file, startline, startcolumn, _, _) - | - c order by file, startline, startcolumn - ) - } } private Location getCallableLocation(Callable c) { @@ -420,15 +410,6 @@ class NodeRegion instanceof BasicBlock { string toString() { result = "NodeRegion" } predicate contains(Node n) { n.getBasicBlock() = this } - - int totalOrder() { - this = - rank[result](BasicBlock b, int startline, int startcolumn | - b.hasLocationInfo(_, startline, startcolumn, _, _) - | - b order by startline, startcolumn - ) - } } /** diff --git a/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll b/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll index f509c8732b09..a380cb30402a 100644 --- a/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll +++ b/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll @@ -400,21 +400,18 @@ class CastNode extends ExprNode { } } -private predicate id_member(Member x, Member y) { x = y } - -private predicate idOf_member(Member x, int y) = equivalenceRelation(id_member/2)(x, y) - -private int summarizedCallableId(SummarizedCallable c) { - c = - rank[result](SummarizedCallable c0, int b, int i, string s | - b = 0 and idOf_member(c0.asCallable(), i) and s = "" - or - b = 1 and i = 0 and s = c0.asSyntheticCallable() - | - c0 order by b, i, s - ) +/** 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 @@ -448,28 +445,10 @@ class DataFlowCallable extends TDataFlowCallable { result = this.asSummarizedCallable().getLocation() or result = this.asFieldScope().getLocation() } - - /** Gets a best-effort total ordering. */ - int totalorder() { - this = - rank[result](DataFlowCallable c, int b, int i | - b = 0 and idOf_member(c.asCallable(), i) - or - b = 1 and i = summarizedCallableId(c.asSummarizedCallable()) - or - b = 2 and idOf_member(c.asFieldScope(), i) - | - c order by b, i - ) - } } class DataFlowExpr = Expr; -private predicate id_call(Call x, Call y) { x = y } - -private predicate idOf_call(Call x, int y) = equivalenceRelation(id_call/2)(x, y) - private newtype TDataFlowCall = TCall(Call c) or TSummaryCall(SummarizedCallable c, FlowSummaryImpl::Private::SummaryNode receiver) { @@ -559,16 +538,10 @@ class SummaryCall extends DataFlowCall, TSummaryCall { override Location getLocation() { result = c.getLocation() } } -private predicate id(BasicBlock x, BasicBlock y) { x = y } - -private predicate idOf(BasicBlock x, int y) = equivalenceRelation(id/2)(x, y) - class NodeRegion instanceof BasicBlock { string toString() { result = "NodeRegion" } predicate contains(Node n) { n.asExpr().getBasicBlock() = this } - - int totalOrder() { idOf(this, result) } } /** Holds if `e` is an expression that always has the same Boolean value `val`. */ diff --git a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll index afbcacec6369..805960347cfa 100644 --- a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll +++ b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll @@ -344,16 +344,6 @@ abstract class DataFlowCallable extends TDataFlowCallable { /** Gets the location of this dataflow callable. */ abstract Location getLocation(); - - /** Gets a best-effort total ordering. */ - int totalorder() { - this = - rank[result](DataFlowCallable c, string file, int startline, int startcolumn | - c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _) - | - c order by file, startline, startcolumn - ) - } } /** A callable function. */ diff --git a/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll b/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll index 9a426eea323e..bc7782e2d9da 100644 --- a/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll +++ b/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll @@ -113,16 +113,6 @@ class DataFlowCallable extends TDataFlowCallable { this instanceof TLibraryCallable and result instanceof EmptyLocation } - - /** Gets a best-effort total ordering. */ - int totalorder() { - this = - rank[result](DataFlowCallable c, string file, int startline, int startcolumn | - c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _) - | - c order by file, startline, startcolumn - ) - } } /** diff --git a/shared/dataflow/codeql/dataflow/DataFlow.qll b/shared/dataflow/codeql/dataflow/DataFlow.qll index 680981ddb31f..36bd9596ec2f 100644 --- a/shared/dataflow/codeql/dataflow/DataFlow.qll +++ b/shared/dataflow/codeql/dataflow/DataFlow.qll @@ -97,9 +97,6 @@ signature module InputSig { /** Gets the location of this callable. */ Location getLocation(); - - /** Gets a best-effort total ordering. */ - int totalorder(); } class ReturnKind { @@ -276,8 +273,6 @@ signature module InputSig { class NodeRegion { /** Holds if this region contains `n`. */ predicate contains(Node n); - - int totalOrder(); } /** diff --git a/swift/ql/lib/codeql/swift/dataflow/internal/DataFlowDispatch.qll b/swift/ql/lib/codeql/swift/dataflow/internal/DataFlowDispatch.qll index 915334031169..687eb00d1efc 100644 --- a/swift/ql/lib/codeql/swift/dataflow/internal/DataFlowDispatch.qll +++ b/swift/ql/lib/codeql/swift/dataflow/internal/DataFlowDispatch.qll @@ -65,16 +65,6 @@ class DataFlowCallable extends TDataFlowCallable { Callable::TypeRange getUnderlyingCallable() { result = this.asSummarizedCallable() or result = this.asSourceCallable() } - - /** Gets a best-effort total ordering. */ - int totalorder() { - this = - rank[result](DataFlowCallable c, string file, int startline, int startcolumn | - c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _) - | - c order by file, startline, startcolumn - ) - } } cached