diff --git a/cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll b/cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll index 9bbc70fbdf9..7da63f6c4fa 100644 --- a/cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll +++ b/cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll @@ -18,6 +18,9 @@ module Consistency { /** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */ predicate uniqueEnclosingCallableExclude(Node n) { none() } + /** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */ + predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() } + /** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */ predicate uniqueNodeLocationExclude(Node n) { none() } @@ -86,6 +89,15 @@ module Consistency { ) } + query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) { + exists(int c | + c = count(call.getEnclosingCallable()) and + c != 1 and + not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and + msg = "Call should have one enclosing callable but has " + c + "." + ) + } + query predicate uniqueType(Node n, string msg) { exists(int c | n instanceof RelevantNode and diff --git a/cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplConsistency.qll b/cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplConsistency.qll index 9bbc70fbdf9..7da63f6c4fa 100644 --- a/cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplConsistency.qll +++ b/cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplConsistency.qll @@ -18,6 +18,9 @@ module Consistency { /** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */ predicate uniqueEnclosingCallableExclude(Node n) { none() } + /** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */ + predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() } + /** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */ predicate uniqueNodeLocationExclude(Node n) { none() } @@ -86,6 +89,15 @@ module Consistency { ) } + query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) { + exists(int c | + c = count(call.getEnclosingCallable()) and + c != 1 and + not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and + msg = "Call should have one enclosing callable but has " + c + "." + ) + } + query predicate uniqueType(Node n, string msg) { exists(int c | n instanceof RelevantNode and diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll index 9bbc70fbdf9..7da63f6c4fa 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll @@ -18,6 +18,9 @@ module Consistency { /** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */ predicate uniqueEnclosingCallableExclude(Node n) { none() } + /** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */ + predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() } + /** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */ predicate uniqueNodeLocationExclude(Node n) { none() } @@ -86,6 +89,15 @@ module Consistency { ) } + query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) { + exists(int c | + c = count(call.getEnclosingCallable()) and + c != 1 and + not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and + msg = "Call should have one enclosing callable but has " + c + "." + ) + } + query predicate uniqueType(Node n, string msg) { exists(int c | n instanceof RelevantNode and diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll index 9bbc70fbdf9..7da63f6c4fa 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll @@ -18,6 +18,9 @@ module Consistency { /** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */ predicate uniqueEnclosingCallableExclude(Node n) { none() } + /** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */ + predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() } + /** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */ predicate uniqueNodeLocationExclude(Node n) { none() } @@ -86,6 +89,15 @@ module Consistency { ) } + query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) { + exists(int c | + c = count(call.getEnclosingCallable()) and + c != 1 and + not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and + msg = "Call should have one enclosing callable but has " + c + "." + ) + } + query predicate uniqueType(Node n, string msg) { exists(int c | n instanceof RelevantNode and diff --git a/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll b/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll index 9bbc70fbdf9..7da63f6c4fa 100644 --- a/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll +++ b/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll @@ -18,6 +18,9 @@ module Consistency { /** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */ predicate uniqueEnclosingCallableExclude(Node n) { none() } + /** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */ + predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() } + /** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */ predicate uniqueNodeLocationExclude(Node n) { none() } @@ -86,6 +89,15 @@ module Consistency { ) } + query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) { + exists(int c | + c = count(call.getEnclosingCallable()) and + c != 1 and + not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and + msg = "Call should have one enclosing callable but has " + c + "." + ) + } + query predicate uniqueType(Node n, string msg) { exists(int c | n instanceof RelevantNode and diff --git a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImplConsistency.qll b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImplConsistency.qll index 9bbc70fbdf9..7da63f6c4fa 100644 --- a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImplConsistency.qll +++ b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImplConsistency.qll @@ -18,6 +18,9 @@ module Consistency { /** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */ predicate uniqueEnclosingCallableExclude(Node n) { none() } + /** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */ + predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() } + /** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */ predicate uniqueNodeLocationExclude(Node n) { none() } @@ -86,6 +89,15 @@ module Consistency { ) } + query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) { + exists(int c | + c = count(call.getEnclosingCallable()) and + c != 1 and + not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and + msg = "Call should have one enclosing callable but has " + c + "." + ) + } + query predicate uniqueType(Node n, string msg) { exists(int c | n instanceof RelevantNode and diff --git a/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplConsistency.qll b/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplConsistency.qll index 9bbc70fbdf9..7da63f6c4fa 100644 --- a/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplConsistency.qll +++ b/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplConsistency.qll @@ -18,6 +18,9 @@ module Consistency { /** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */ predicate uniqueEnclosingCallableExclude(Node n) { none() } + /** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */ + predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() } + /** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */ predicate uniqueNodeLocationExclude(Node n) { none() } @@ -86,6 +89,15 @@ module Consistency { ) } + query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) { + exists(int c | + c = count(call.getEnclosingCallable()) and + c != 1 and + not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and + msg = "Call should have one enclosing callable but has " + c + "." + ) + } + query predicate uniqueType(Node n, string msg) { exists(int c | n instanceof RelevantNode and diff --git a/swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImplConsistency.qll b/swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImplConsistency.qll index 9bbc70fbdf9..7da63f6c4fa 100644 --- a/swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImplConsistency.qll +++ b/swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImplConsistency.qll @@ -18,6 +18,9 @@ module Consistency { /** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */ predicate uniqueEnclosingCallableExclude(Node n) { none() } + /** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */ + predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() } + /** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */ predicate uniqueNodeLocationExclude(Node n) { none() } @@ -86,6 +89,15 @@ module Consistency { ) } + query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) { + exists(int c | + c = count(call.getEnclosingCallable()) and + c != 1 and + not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and + msg = "Call should have one enclosing callable but has " + c + "." + ) + } + query predicate uniqueType(Node n, string msg) { exists(int c | n instanceof RelevantNode and