mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
Merge pull request #9928 from asgerf/js/source-node-type
JS: Simplify type hierarchy for SourceNode
This commit is contained in:
@@ -33,13 +33,7 @@ private import semmle.javascript.internal.CachedStages
|
|||||||
* import("fs")
|
* import("fs")
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
class SourceNode extends DataFlow::Node {
|
class SourceNode extends DataFlow::Node instanceof SourceNode::Range {
|
||||||
SourceNode() {
|
|
||||||
this instanceof SourceNode::Range
|
|
||||||
or
|
|
||||||
none() and this instanceof SourceNode::Internal::RecursionGuard
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds if this node flows into `sink` in zero or more local (that is,
|
* Holds if this node flows into `sink` in zero or more local (that is,
|
||||||
* intra-procedural) steps.
|
* intra-procedural) steps.
|
||||||
@@ -340,12 +334,6 @@ module SourceNode {
|
|||||||
DataFlow::functionReturnNode(this, _)
|
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 {
|
private class NodeModuleSourcesNodes extends SourceNode::Range {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
| Success |
|
|
||||||
@@ -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"
|
|
||||||
Reference in New Issue
Block a user