From 98a9cb0b559c0c3ed98321e5e73ab931fcdc17c9 Mon Sep 17 00:00:00 2001 From: Asger F Date: Fri, 29 Jul 2022 19:44:10 +0200 Subject: [PATCH] JS: Simplify type hierarchy for SourceNode The charpred caused spurious type to appear --- .../ql/lib/semmle/javascript/dataflow/Sources.qll | 14 +------------- .../RecursionPrevention/SourceNodeRange.expected | 1 - .../RecursionPrevention/SourceNodeRange.ql | 14 -------------- 3 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 javascript/ql/test/library-tests/RecursionPrevention/SourceNodeRange.expected delete mode 100644 javascript/ql/test/library-tests/RecursionPrevention/SourceNodeRange.ql diff --git a/javascript/ql/lib/semmle/javascript/dataflow/Sources.qll b/javascript/ql/lib/semmle/javascript/dataflow/Sources.qll index 73d3f9c96ac..8813b974add 100644 --- a/javascript/ql/lib/semmle/javascript/dataflow/Sources.qll +++ b/javascript/ql/lib/semmle/javascript/dataflow/Sources.qll @@ -33,13 +33,7 @@ private import semmle.javascript.internal.CachedStages * import("fs") * ``` */ -class SourceNode extends DataFlow::Node { - SourceNode() { - this instanceof SourceNode::Range - or - none() and this instanceof SourceNode::Internal::RecursionGuard - } - +class SourceNode extends DataFlow::Node instanceof SourceNode::Range { /** * Holds if this node flows into `sink` in zero or more local (that is, * intra-procedural) steps. @@ -340,12 +334,6 @@ module SourceNode { DataFlow::functionReturnNode(this, _) } } - - /** INTERNAL. DO NOT USE. */ - module Internal { - /** An empty class that some tests are using to enforce that SourceNode is non-recursive. */ - abstract class RecursionGuard extends DataFlow::Node { } - } } private class NodeModuleSourcesNodes extends SourceNode::Range { diff --git a/javascript/ql/test/library-tests/RecursionPrevention/SourceNodeRange.expected b/javascript/ql/test/library-tests/RecursionPrevention/SourceNodeRange.expected deleted file mode 100644 index 59f6fd6e79b..00000000000 --- a/javascript/ql/test/library-tests/RecursionPrevention/SourceNodeRange.expected +++ /dev/null @@ -1 +0,0 @@ -| Success | diff --git a/javascript/ql/test/library-tests/RecursionPrevention/SourceNodeRange.ql b/javascript/ql/test/library-tests/RecursionPrevention/SourceNodeRange.ql deleted file mode 100644 index 03549a97873..00000000000 --- a/javascript/ql/test/library-tests/RecursionPrevention/SourceNodeRange.ql +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Test that fails to compile if the domain of `SourceNode::Range` depends on `SourceNode` (recursively). - * - * This tests adds a negative dependency `SourceNode --!--> SourceNode::Range` - * so that the undesired edge `SourceNode::Range --> SourceNode` completes a negative cycle. - */ - -import javascript - -class BadSourceNodeRange extends DataFlow::SourceNode::Internal::RecursionGuard { - BadSourceNodeRange() { not this instanceof DataFlow::SourceNode::Range } -} - -select "Success"