mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
JS: Move React test predicates into one file
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_ReactComponent(ReactComponent c) { any() }
|
||||
@@ -1,5 +0,0 @@
|
||||
import javascript
|
||||
|
||||
query predicate test_ReactComponent_getACandidatePropsValue(DataFlow::Node res) {
|
||||
exists(ReactComponent c | res = c.getACandidatePropsValue(_))
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_ReactComponent_getACandidateStateSource(
|
||||
ReactComponent c, DataFlow::SourceNode res
|
||||
) {
|
||||
res = c.getACandidateStateSource()
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_ReactComponent_getADirectPropsSource(ReactComponent c, DataFlow::SourceNode res) {
|
||||
res = c.getADirectPropsAccess()
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_ReactComponent_getAPreviousStateSource(
|
||||
ReactComponent c, DataFlow::SourceNode res
|
||||
) {
|
||||
res = c.getAPreviousStateSource()
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_ReactComponent_getAPropRead(ReactComponent c, string n, DataFlow::PropRead res) {
|
||||
res = c.getAPropRead(n)
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_ReactComponent_getInstanceMethod(ReactComponent c, string n, Function res) {
|
||||
res = c.getInstanceMethod(n)
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_ReactComponent_ref(ReactComponent c, DataFlow::Node res) { res = c.ref() }
|
||||
@@ -1,17 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_JSXname(JsxElement element, JsxName jsxname, string name, string type) {
|
||||
name = jsxname.getValue() and
|
||||
(
|
||||
jsxname instanceof Identifier and type = "Identifier"
|
||||
or
|
||||
jsxname instanceof ThisExpr and type = "thisExpr"
|
||||
or
|
||||
jsxname.(DotExpr).getBase() instanceof JsxName and type = "dot"
|
||||
or
|
||||
jsxname instanceof JsxQualifiedName and type = "qualifiedName"
|
||||
) and
|
||||
element.getNameExpr() = jsxname
|
||||
}
|
||||
|
||||
query ThisExpr test_JsxName_this(JsxElement element) { result.getParentExpr+() = element }
|
||||
@@ -1,5 +0,0 @@
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_getADirectStateAccess(ReactComponent c, DataFlow::SourceNode res) {
|
||||
res = c.getADirectStateAccess()
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
import javascript
|
||||
|
||||
query predicate test_react(DataFlow::ValueNode nd) { react().flowsTo(nd) }
|
||||
@@ -1,14 +1,59 @@
|
||||
import getADirectStateAccess
|
||||
import ReactComponent_getInstanceMethod
|
||||
import react
|
||||
import ReactComponent_getAPreviousStateSource
|
||||
import ReactComponent_ref
|
||||
import ReactComponent_getACandidateStateSource
|
||||
import ReactComponent_getADirectPropsSource
|
||||
import ReactComponent_getACandidatePropsValue
|
||||
import ReactComponent
|
||||
import ReactComponent_getAPropRead
|
||||
import ReactName
|
||||
import javascript
|
||||
import semmle.javascript.frameworks.React
|
||||
|
||||
query predicate test_getADirectStateAccess(ReactComponent c, DataFlow::SourceNode res) {
|
||||
res = c.getADirectStateAccess()
|
||||
}
|
||||
|
||||
query predicate test_ReactComponent_getInstanceMethod(ReactComponent c, string n, Function res) {
|
||||
res = c.getInstanceMethod(n)
|
||||
}
|
||||
|
||||
query predicate test_react(DataFlow::ValueNode nd) { react().flowsTo(nd) }
|
||||
|
||||
query predicate test_ReactComponent_getAPreviousStateSource(
|
||||
ReactComponent c, DataFlow::SourceNode res
|
||||
) {
|
||||
res = c.getAPreviousStateSource()
|
||||
}
|
||||
|
||||
query predicate test_ReactComponent_ref(ReactComponent c, DataFlow::Node res) { res = c.ref() }
|
||||
|
||||
query predicate test_ReactComponent_getACandidateStateSource(
|
||||
ReactComponent c, DataFlow::SourceNode res
|
||||
) {
|
||||
res = c.getACandidateStateSource()
|
||||
}
|
||||
|
||||
query predicate test_ReactComponent_getADirectPropsSource(ReactComponent c, DataFlow::SourceNode res) {
|
||||
res = c.getADirectPropsAccess()
|
||||
}
|
||||
|
||||
query predicate test_ReactComponent_getACandidatePropsValue(DataFlow::Node res) {
|
||||
exists(ReactComponent c | res = c.getACandidatePropsValue(_))
|
||||
}
|
||||
|
||||
query predicate test_ReactComponent(ReactComponent c) { any() }
|
||||
|
||||
query predicate test_ReactComponent_getAPropRead(ReactComponent c, string n, DataFlow::PropRead res) {
|
||||
res = c.getAPropRead(n)
|
||||
}
|
||||
|
||||
query predicate test_JSXname(JsxElement element, JsxName jsxname, string name, string type) {
|
||||
name = jsxname.getValue() and
|
||||
(
|
||||
jsxname instanceof Identifier and type = "Identifier"
|
||||
or
|
||||
jsxname instanceof ThisExpr and type = "thisExpr"
|
||||
or
|
||||
jsxname.(DotExpr).getBase() instanceof JsxName and type = "dot"
|
||||
or
|
||||
jsxname instanceof JsxQualifiedName and type = "qualifiedName"
|
||||
) and
|
||||
element.getNameExpr() = jsxname
|
||||
}
|
||||
|
||||
query ThisExpr test_JsxName_this(JsxElement element) { result.getParentExpr+() = element }
|
||||
|
||||
query DataFlow::SourceNode locationSource() { result = DOM::locationSource() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user