mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
JS: replace .stripParens library uses w. .getUnderlyingValue
This commit is contained in:
@@ -172,7 +172,7 @@ class AMDModuleDefinition extends CallExpr {
|
||||
* Gets a call to `require` inside this module.
|
||||
*/
|
||||
CallExpr getARequireCall() {
|
||||
result.getCallee().stripParens() = getRequireVariable().getAnAccess()
|
||||
result.getCallee().getUnderlyingValue() = getRequireVariable().getAnAccess()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ class SuperExpr extends @superexpr, Expr {
|
||||
*/
|
||||
class SuperCall extends CallExpr {
|
||||
SuperCall() {
|
||||
getCallee().stripParens() instanceof SuperExpr
|
||||
getCallee().getUnderlyingValue() instanceof SuperExpr
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,7 +299,7 @@ class SuperCall extends CallExpr {
|
||||
* which is the nearest enclosing non-arrow function.
|
||||
*/
|
||||
Function getBinder() {
|
||||
result = getCallee().stripParens().(SuperExpr).getBinder()
|
||||
result = getCallee().getUnderlyingValue().(SuperExpr).getBinder()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ class SuperCall extends CallExpr {
|
||||
*/
|
||||
class SuperPropAccess extends PropAccess {
|
||||
SuperPropAccess() {
|
||||
getBase().stripParens() instanceof SuperExpr
|
||||
getBase().getUnderlyingValue() instanceof SuperExpr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -710,7 +710,7 @@ class InvokeExpr extends @invokeexpr, Expr {
|
||||
|
||||
/** Gets the name of the function or method being invoked, if it can be determined. */
|
||||
string getCalleeName() {
|
||||
exists (Expr callee | callee = getCallee().stripParens() |
|
||||
exists (Expr callee | callee = getCallee().getUnderlyingValue() |
|
||||
result = ((Identifier)callee).getName() or
|
||||
result = ((PropAccess)callee).getPropertyName()
|
||||
)
|
||||
@@ -1690,10 +1690,10 @@ class ImmediatelyInvokedFunctionExpr extends Function {
|
||||
|
||||
ImmediatelyInvokedFunctionExpr() {
|
||||
// direct call
|
||||
this = invk.getCallee().stripParens() and kind = "direct" or
|
||||
this = invk.getCallee().getUnderlyingValue() and kind = "direct" or
|
||||
// reflective call
|
||||
exists (MethodCallExpr mce | mce = invk |
|
||||
this = mce.getReceiver().stripParens() and
|
||||
this = mce.getReceiver().getUnderlyingValue() and
|
||||
kind = mce.getMethodName() and
|
||||
(kind = "call" or kind = "apply")
|
||||
)
|
||||
|
||||
@@ -159,7 +159,7 @@ private class AnalyzedJSXEmptyExpression extends DataFlow::AnalyzedValueNode{
|
||||
*/
|
||||
private class AnalyzedSuperCall extends DataFlow::AnalyzedValueNode {
|
||||
AnalyzedSuperCall() {
|
||||
astNode = any(SuperCall sc).getCallee().stripParens()
|
||||
astNode = any(SuperCall sc).getCallee().getUnderlyingValue()
|
||||
}
|
||||
|
||||
override AbstractValue getALocalValue() {
|
||||
|
||||
@@ -36,7 +36,7 @@ predicate isBrowserifyBundle(ObjectExpr oe) {
|
||||
isBrowserifyBundledModule(p)
|
||||
) and
|
||||
// the whole object must be passed to the module loader function
|
||||
exists (CallExpr ce | ce.getCallee().stripParens() instanceof Function |
|
||||
exists (CallExpr ce | ce.getCallee().getUnderlyingValue() instanceof Function |
|
||||
// the module loader function always has three arguments
|
||||
ce.getNumArgument() = 3 and
|
||||
// the first of which is the bundle
|
||||
@@ -140,10 +140,10 @@ private predicate isWebpackModule(FunctionExpr m) {
|
||||
*/
|
||||
predicate isWebpackBundle(ArrayExpr ae) {
|
||||
// ensure that there is at least one bundled module
|
||||
isWebpackModule(ae.getAnElement().stripParens())
|
||||
isWebpackModule(ae.getAnElement().getUnderlyingValue())
|
||||
and
|
||||
// furthermore, every element is either
|
||||
forall (Expr elt | elt = ae.getAnElement().stripParens() |
|
||||
forall (Expr elt | elt = ae.getAnElement().getUnderlyingValue() |
|
||||
// (1) a module
|
||||
isWebpackModule(elt)
|
||||
or
|
||||
@@ -158,7 +158,7 @@ predicate isWebpackBundle(ArrayExpr ae) {
|
||||
)
|
||||
and
|
||||
// the whole array must be passed to a module loader function
|
||||
exists (CallExpr ce | ce.getCallee().stripParens() instanceof Function |
|
||||
exists (CallExpr ce | ce.getCallee().getUnderlyingValue() instanceof Function |
|
||||
// which is the bundle
|
||||
ce.getArgument(0) = ae
|
||||
)
|
||||
|
||||
@@ -16,10 +16,10 @@ import javascript
|
||||
bindingset[regexp]
|
||||
predicate isReadFrom(DataFlow::Node read, string regexp) {
|
||||
exists (DataFlow::Node actualRead |
|
||||
actualRead = read.asExpr().stripParens().(LogOrExpr).getAnOperand().flow() or // unfold `x || y` once
|
||||
actualRead = read.asExpr().getUnderlyingValue().(LogOrExpr).getAnOperand().flow() or // unfold `x || y` once
|
||||
actualRead = read |
|
||||
exists (string name | name.regexpMatch(regexp) |
|
||||
actualRead.asExpr().stripParens().(VarAccess).getName() = name or
|
||||
actualRead.asExpr().getUnderlyingValue().(VarAccess).getName() = name or
|
||||
actualRead.(DataFlow::PropRead).getPropertyName() = name or
|
||||
actualRead.(DataFlow::InvokeNode).getCalleeName() = "get" + name
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user