From fdd3b901f798f02ea1828d3bf79e43d0f12c6049 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 21 Aug 2019 13:04:10 +0200 Subject: [PATCH 1/3] C/C#/Java: Share ConfigurationRecursionPrevention This class was copy-pasted in all `DataFlowN.qll` files without using the identical-files system to keep the copies in sync. The class is now moved to the `DataFlowImplN.qll` files. This also has the effect of preventing recursion through first data flow library copy for C/C++. Such recursion has been deprecated for over a year, and some forms of recursions are already ruled out by the library implementation. --- .../semmle/code/cpp/dataflow/DataFlow2.qll | 23 ------------------- .../semmle/code/cpp/dataflow/DataFlow3.qll | 23 ------------------- .../semmle/code/cpp/dataflow/DataFlow4.qll | 23 ------------------- .../cpp/dataflow/internal/DataFlowImpl.qll | 22 ++++++++++++++++++ .../cpp/dataflow/internal/DataFlowImpl2.qll | 22 ++++++++++++++++++ .../cpp/dataflow/internal/DataFlowImpl3.qll | 22 ++++++++++++++++++ .../cpp/dataflow/internal/DataFlowImpl4.qll | 22 ++++++++++++++++++ .../semmle/code/cpp/ir/dataflow/DataFlow2.qll | 23 ------------------- .../semmle/code/cpp/ir/dataflow/DataFlow3.qll | 23 ------------------- .../semmle/code/cpp/ir/dataflow/DataFlow4.qll | 23 ------------------- .../cpp/ir/dataflow/internal/DataFlowImpl.qll | 22 ++++++++++++++++++ .../ir/dataflow/internal/DataFlowImpl2.qll | 22 ++++++++++++++++++ .../ir/dataflow/internal/DataFlowImpl3.qll | 22 ++++++++++++++++++ .../ir/dataflow/internal/DataFlowImpl4.qll | 22 ++++++++++++++++++ .../semmle/code/csharp/dataflow/DataFlow.qll | 19 --------------- .../semmle/code/csharp/dataflow/DataFlow2.qll | 19 --------------- .../semmle/code/csharp/dataflow/DataFlow3.qll | 19 --------------- .../semmle/code/csharp/dataflow/DataFlow4.qll | 19 --------------- .../semmle/code/csharp/dataflow/DataFlow5.qll | 19 --------------- .../csharp/dataflow/internal/DataFlowImpl.qll | 22 ++++++++++++++++++ .../dataflow/internal/DataFlowImpl2.qll | 22 ++++++++++++++++++ .../dataflow/internal/DataFlowImpl3.qll | 22 ++++++++++++++++++ .../dataflow/internal/DataFlowImpl4.qll | 22 ++++++++++++++++++ .../dataflow/internal/DataFlowImpl5.qll | 22 ++++++++++++++++++ .../semmle/code/java/dataflow/DataFlow.qll | 19 --------------- .../semmle/code/java/dataflow/DataFlow2.qll | 19 --------------- .../semmle/code/java/dataflow/DataFlow3.qll | 19 --------------- .../semmle/code/java/dataflow/DataFlow4.qll | 19 --------------- .../semmle/code/java/dataflow/DataFlow5.qll | 19 --------------- .../java/dataflow/internal/DataFlowImpl.qll | 22 ++++++++++++++++++ .../java/dataflow/internal/DataFlowImpl2.qll | 22 ++++++++++++++++++ .../java/dataflow/internal/DataFlowImpl3.qll | 22 ++++++++++++++++++ .../java/dataflow/internal/DataFlowImpl4.qll | 22 ++++++++++++++++++ .../java/dataflow/internal/DataFlowImpl5.qll | 22 ++++++++++++++++++ 34 files changed, 396 insertions(+), 328 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow2.qll b/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow2.qll index 6f6c41ee16c..c651ead3b01 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow2.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow2.qll @@ -12,27 +12,4 @@ import cpp module DataFlow2 { import semmle.code.cpp.dataflow.internal.DataFlowImpl2 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - private abstract - class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 - or - strictcount(Node n | this.isSink(n)) < 0 - or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 - or - super.hasFlow(source, sink) - } - } } diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow3.qll b/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow3.qll index 77385b2dbe5..53293eb2f22 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow3.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow3.qll @@ -12,27 +12,4 @@ import cpp module DataFlow3 { import semmle.code.cpp.dataflow.internal.DataFlowImpl3 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - private abstract - class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 - or - strictcount(Node n | this.isSink(n)) < 0 - or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 - or - super.hasFlow(source, sink) - } - } } diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow4.qll b/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow4.qll index 30b7273f451..c4963e46a7b 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow4.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/DataFlow4.qll @@ -12,27 +12,4 @@ import cpp module DataFlow4 { import semmle.code.cpp.dataflow.internal.DataFlowImpl4 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - private abstract - class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 - or - strictcount(Node n | this.isSink(n)) < 0 - or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 - or - super.hasFlow(source, sink) - } - } } diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll index f797b3bcf35..96238a91d09 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll index f797b3bcf35..96238a91d09 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll index f797b3bcf35..96238a91d09 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll index f797b3bcf35..96238a91d09 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow2.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow2.qll index 9d849c510c5..0e24e2949f0 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow2.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow2.qll @@ -12,27 +12,4 @@ import cpp module DataFlow2 { import semmle.code.cpp.ir.dataflow.internal.DataFlowImpl2 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - private abstract - class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 - or - strictcount(Node n | this.isSink(n)) < 0 - or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 - or - super.hasFlow(source, sink) - } - } } diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow3.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow3.qll index 459b80d5e27..9ea19b45a37 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow3.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow3.qll @@ -12,27 +12,4 @@ import cpp module DataFlow3 { import semmle.code.cpp.ir.dataflow.internal.DataFlowImpl3 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - private abstract - class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 - or - strictcount(Node n | this.isSink(n)) < 0 - or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 - or - super.hasFlow(source, sink) - } - } } diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow4.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow4.qll index c67509bd7e4..cd9bb5869c1 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow4.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow4.qll @@ -12,27 +12,4 @@ import cpp module DataFlow4 { import semmle.code.cpp.ir.dataflow.internal.DataFlowImpl4 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - private abstract - class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 - or - strictcount(Node n | this.isSink(n)) < 0 - or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 - or - super.hasFlow(source, sink) - } - } } diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll index f797b3bcf35..96238a91d09 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll index f797b3bcf35..96238a91d09 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll index f797b3bcf35..96238a91d09 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll index f797b3bcf35..96238a91d09 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow.qll b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow.qll index d7e7106694a..1d3d53e2316 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow.qll @@ -7,23 +7,4 @@ import csharp module DataFlow { import semmle.code.csharp.dataflow.internal.DataFlowImpl - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Five copies are available: `DataFlow` through `DataFlow5`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow2.qll b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow2.qll index b2e18f6ef11..60525016d31 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow2.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow2.qll @@ -7,23 +7,4 @@ import csharp module DataFlow2 { import semmle.code.csharp.dataflow.internal.DataFlowImpl2 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Five copies are available: `DataFlow` through `DataFlow5`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow3.qll b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow3.qll index 6d3fcc86b0b..7f3b9469449 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow3.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow3.qll @@ -7,23 +7,4 @@ import csharp module DataFlow3 { import semmle.code.csharp.dataflow.internal.DataFlowImpl3 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Five copies are available: `DataFlow` through `DataFlow5`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow4.qll b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow4.qll index 7334e406a4a..29c994a2eec 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow4.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow4.qll @@ -7,23 +7,4 @@ import csharp module DataFlow4 { import semmle.code.csharp.dataflow.internal.DataFlowImpl4 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Five copies are available: `DataFlow` through `DataFlow5`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow5.qll b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow5.qll index 6990f0b2e51..48148117166 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow5.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/DataFlow5.qll @@ -7,23 +7,4 @@ import csharp module DataFlow5 { import semmle.code.csharp.dataflow.internal.DataFlowImpl5 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Five copies are available: `DataFlow` through `DataFlow5`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll index f797b3bcf35..96238a91d09 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll index f797b3bcf35..96238a91d09 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll index f797b3bcf35..96238a91d09 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll index f797b3bcf35..96238a91d09 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll index f797b3bcf35..96238a91d09 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/java/ql/src/semmle/code/java/dataflow/DataFlow.qll b/java/ql/src/semmle/code/java/dataflow/DataFlow.qll index c6d12c8f657..1b4409234e6 100644 --- a/java/ql/src/semmle/code/java/dataflow/DataFlow.qll +++ b/java/ql/src/semmle/code/java/dataflow/DataFlow.qll @@ -7,23 +7,4 @@ import java module DataFlow { import semmle.code.java.dataflow.internal.DataFlowImpl - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/java/ql/src/semmle/code/java/dataflow/DataFlow2.qll b/java/ql/src/semmle/code/java/dataflow/DataFlow2.qll index 43e319b503b..92003314778 100644 --- a/java/ql/src/semmle/code/java/dataflow/DataFlow2.qll +++ b/java/ql/src/semmle/code/java/dataflow/DataFlow2.qll @@ -7,23 +7,4 @@ import java module DataFlow2 { import semmle.code.java.dataflow.internal.DataFlowImpl2 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/java/ql/src/semmle/code/java/dataflow/DataFlow3.qll b/java/ql/src/semmle/code/java/dataflow/DataFlow3.qll index 5a9cc7cdb1a..c8d614e0879 100644 --- a/java/ql/src/semmle/code/java/dataflow/DataFlow3.qll +++ b/java/ql/src/semmle/code/java/dataflow/DataFlow3.qll @@ -7,23 +7,4 @@ import java module DataFlow3 { import semmle.code.java.dataflow.internal.DataFlowImpl3 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/java/ql/src/semmle/code/java/dataflow/DataFlow4.qll b/java/ql/src/semmle/code/java/dataflow/DataFlow4.qll index 1df0d5db293..852cfd9f813 100644 --- a/java/ql/src/semmle/code/java/dataflow/DataFlow4.qll +++ b/java/ql/src/semmle/code/java/dataflow/DataFlow4.qll @@ -7,23 +7,4 @@ import java module DataFlow4 { import semmle.code.java.dataflow.internal.DataFlowImpl4 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/java/ql/src/semmle/code/java/dataflow/DataFlow5.qll b/java/ql/src/semmle/code/java/dataflow/DataFlow5.qll index b932e7d0d10..f8986a03524 100644 --- a/java/ql/src/semmle/code/java/dataflow/DataFlow5.qll +++ b/java/ql/src/semmle/code/java/dataflow/DataFlow5.qll @@ -7,23 +7,4 @@ import java module DataFlow5 { import semmle.code.java.dataflow.internal.DataFlowImpl5 - - /** - * This class exists to prevent mutual recursion between the user-overridden - * member predicates of `Configuration` and the rest of the data-flow library. - * Good performance cannot be guaranteed in the presence of such recursion, so - * it should be replaced by using more than one copy of the data flow library. - * Four copies are available: `DataFlow` through `DataFlow4`. - */ - abstract private class ConfigurationRecursionPrevention extends Configuration { - bindingset[this] - ConfigurationRecursionPrevention() { any() } - - override predicate hasFlow(Node source, Node sink) { - strictcount(Node n | this.isSource(n)) < 0 or - strictcount(Node n | this.isSink(n)) < 0 or - strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or - super.hasFlow(source, sink) - } - } } diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll index f797b3bcf35..96238a91d09 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll index f797b3bcf35..96238a91d09 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll index f797b3bcf35..96238a91d09 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll index f797b3bcf35..96238a91d09 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll index f797b3bcf35..96238a91d09 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll @@ -121,6 +121,28 @@ abstract class Configuration extends string { deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) } } +/** + * This class exists to prevent mutual recursion between the user-overridden + * member predicates of `Configuration` and the rest of the data-flow library. + * Good performance cannot be guaranteed in the presence of such recursion, so + * it should be replaced by using more than one copy of the data flow library. + */ +private abstract +class ConfigurationRecursionPrevention extends Configuration { + bindingset[this] + ConfigurationRecursionPrevention() { any() } + + override predicate hasFlow(Node source, Node sink) { + strictcount(Node n | this.isSource(n)) < 0 + or + strictcount(Node n | this.isSink(n)) < 0 + or + strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 + or + super.hasFlow(source, sink) + } +} + private predicate inBarrier(Node node, Configuration config) { config.isBarrierIn(node) and config.isSource(node) From 846e3734cee01a2ea0068b44336e9aa43bca4c27 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 21 Aug 2019 13:12:48 +0200 Subject: [PATCH 2/3] C++: Change note for recursion prevention --- change-notes/1.22/analysis-cpp.md | 1 + 1 file changed, 1 insertion(+) diff --git a/change-notes/1.22/analysis-cpp.md b/change-notes/1.22/analysis-cpp.md index 75548c0290b..ad3ff8b8385 100644 --- a/change-notes/1.22/analysis-cpp.md +++ b/change-notes/1.22/analysis-cpp.md @@ -29,3 +29,4 @@ - Fixed the `LocalScopeVariableReachability.qll` library's handling of loops with an entry condition is both always true upon first entry, and where there is more than one control flow path through the loop condition. This change increases the accuracy of the `LocalScopeVariableReachability.qll` library and queries which depend on it. - The `semmle.code.cpp.models` library now models data flow through `std::swap`. - There is a new `Variable.isThreadLocal()` predicate. It can be used to tell whether a variable is `thread_local`. +- Recursion through the `DataFlow` library is now always a compile error. Such recursion has been deprecated since release 1.16. If one `DataFlow::Configuration` needs to depend on the results of another, switch one of them to use one of the `DataFlow2` through `DataFlow4` libraries. From 863bf523d6c1dffc2968afa145ed78c0c4a2fd12 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 21 Aug 2019 13:24:01 +0200 Subject: [PATCH 3/3] C++/C#/Java: Autoformat --- cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll | 3 +-- cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll | 3 +-- cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll | 3 +-- cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll | 3 +-- .../src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll | 3 +-- .../src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll | 3 +-- .../src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll | 3 +-- .../src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll | 3 +-- .../src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll | 3 +-- .../src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll | 3 +-- .../src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll | 3 +-- .../src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll | 3 +-- .../src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll | 3 +-- .../ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll | 3 +-- .../src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll | 3 +-- .../src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll | 3 +-- .../src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll | 3 +-- .../src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll | 3 +-- 18 files changed, 18 insertions(+), 36 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll index 96238a91d09..4b425f1d6ef 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll index 96238a91d09..4b425f1d6ef 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll index 96238a91d09..4b425f1d6ef 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll index 96238a91d09..4b425f1d6ef 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll index 96238a91d09..4b425f1d6ef 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll index 96238a91d09..4b425f1d6ef 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll index 96238a91d09..4b425f1d6ef 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll index 96238a91d09..4b425f1d6ef 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll index 96238a91d09..4b425f1d6ef 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll index 96238a91d09..4b425f1d6ef 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll index 96238a91d09..4b425f1d6ef 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll index 96238a91d09..4b425f1d6ef 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll index 96238a91d09..4b425f1d6ef 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll index 96238a91d09..4b425f1d6ef 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll index 96238a91d09..4b425f1d6ef 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll index 96238a91d09..4b425f1d6ef 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll index 96238a91d09..4b425f1d6ef 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() } diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll index 96238a91d09..4b425f1d6ef 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll @@ -127,8 +127,7 @@ abstract class Configuration extends string { * Good performance cannot be guaranteed in the presence of such recursion, so * it should be replaced by using more than one copy of the data flow library. */ -private abstract -class ConfigurationRecursionPrevention extends Configuration { +abstract private class ConfigurationRecursionPrevention extends Configuration { bindingset[this] ConfigurationRecursionPrevention() { any() }