Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 030d920

Browse files
author
Esben Sparre Andreasen
committed
JS: replace .stripParens library uses w. .getUnderlyingValue
1 parent c20e24d commit 030d920

6 files changed

Lines changed: 14 additions & 14 deletions

File tree

javascript/ql/src/semmle/javascript/AMD.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class AMDModuleDefinition extends CallExpr {
172172
* Gets a call to `require` inside this module.
173173
*/
174174
CallExpr getARequireCall() {
175-
result.getCallee().stripParens() = getRequireVariable().getAnAccess()
175+
result.getCallee().getUnderlyingValue() = getRequireVariable().getAnAccess()
176176
}
177177
}
178178

javascript/ql/src/semmle/javascript/Classes.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ class SuperExpr extends @superexpr, Expr {
291291
*/
292292
class SuperCall extends CallExpr {
293293
SuperCall() {
294-
getCallee().stripParens() instanceof SuperExpr
294+
getCallee().getUnderlyingValue() instanceof SuperExpr
295295
}
296296

297297
/**
298298
* Gets the function whose `super` binding this call refers to,
299299
* which is the nearest enclosing non-arrow function.
300300
*/
301301
Function getBinder() {
302-
result = getCallee().stripParens().(SuperExpr).getBinder()
302+
result = getCallee().getUnderlyingValue().(SuperExpr).getBinder()
303303
}
304304
}
305305

@@ -308,7 +308,7 @@ class SuperCall extends CallExpr {
308308
*/
309309
class SuperPropAccess extends PropAccess {
310310
SuperPropAccess() {
311-
getBase().stripParens() instanceof SuperExpr
311+
getBase().getUnderlyingValue() instanceof SuperExpr
312312
}
313313
}
314314

javascript/ql/src/semmle/javascript/Expr.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ class InvokeExpr extends @invokeexpr, Expr {
710710

711711
/** Gets the name of the function or method being invoked, if it can be determined. */
712712
string getCalleeName() {
713-
exists (Expr callee | callee = getCallee().stripParens() |
713+
exists (Expr callee | callee = getCallee().getUnderlyingValue() |
714714
result = ((Identifier)callee).getName() or
715715
result = ((PropAccess)callee).getPropertyName()
716716
)
@@ -1690,10 +1690,10 @@ class ImmediatelyInvokedFunctionExpr extends Function {
16901690

16911691
ImmediatelyInvokedFunctionExpr() {
16921692
// direct call
1693-
this = invk.getCallee().stripParens() and kind = "direct" or
1693+
this = invk.getCallee().getUnderlyingValue() and kind = "direct" or
16941694
// reflective call
16951695
exists (MethodCallExpr mce | mce = invk |
1696-
this = mce.getReceiver().stripParens() and
1696+
this = mce.getReceiver().getUnderlyingValue() and
16971697
kind = mce.getMethodName() and
16981698
(kind = "call" or kind = "apply")
16991699
)

javascript/ql/src/semmle/javascript/dataflow/internal/BasicExprTypeInference.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private class AnalyzedJSXEmptyExpression extends DataFlow::AnalyzedValueNode{
159159
*/
160160
private class AnalyzedSuperCall extends DataFlow::AnalyzedValueNode {
161161
AnalyzedSuperCall() {
162-
astNode = any(SuperCall sc).getCallee().stripParens()
162+
astNode = any(SuperCall sc).getCallee().getUnderlyingValue()
163163
}
164164

165165
override AbstractValue getALocalValue() {

javascript/ql/src/semmle/javascript/frameworks/Bundling.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ predicate isBrowserifyBundle(ObjectExpr oe) {
3636
isBrowserifyBundledModule(p)
3737
) and
3838
// the whole object must be passed to the module loader function
39-
exists (CallExpr ce | ce.getCallee().stripParens() instanceof Function |
39+
exists (CallExpr ce | ce.getCallee().getUnderlyingValue() instanceof Function |
4040
// the module loader function always has three arguments
4141
ce.getNumArgument() = 3 and
4242
// the first of which is the bundle
@@ -140,10 +140,10 @@ private predicate isWebpackModule(FunctionExpr m) {
140140
*/
141141
predicate isWebpackBundle(ArrayExpr ae) {
142142
// ensure that there is at least one bundled module
143-
isWebpackModule(ae.getAnElement().stripParens())
143+
isWebpackModule(ae.getAnElement().getUnderlyingValue())
144144
and
145145
// furthermore, every element is either
146-
forall (Expr elt | elt = ae.getAnElement().stripParens() |
146+
forall (Expr elt | elt = ae.getAnElement().getUnderlyingValue() |
147147
// (1) a module
148148
isWebpackModule(elt)
149149
or
@@ -158,7 +158,7 @@ predicate isWebpackBundle(ArrayExpr ae) {
158158
)
159159
and
160160
// the whole array must be passed to a module loader function
161-
exists (CallExpr ce | ce.getCallee().stripParens() instanceof Function |
161+
exists (CallExpr ce | ce.getCallee().getUnderlyingValue() instanceof Function |
162162
// which is the bundle
163163
ce.getArgument(0) = ae
164164
)

javascript/ql/src/semmle/javascript/heuristics/SyntacticHeuristics.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import javascript
1616
bindingset[regexp]
1717
predicate isReadFrom(DataFlow::Node read, string regexp) {
1818
exists (DataFlow::Node actualRead |
19-
actualRead = read.asExpr().stripParens().(LogOrExpr).getAnOperand().flow() or // unfold `x || y` once
19+
actualRead = read.asExpr().getUnderlyingValue().(LogOrExpr).getAnOperand().flow() or // unfold `x || y` once
2020
actualRead = read |
2121
exists (string name | name.regexpMatch(regexp) |
22-
actualRead.asExpr().stripParens().(VarAccess).getName() = name or
22+
actualRead.asExpr().getUnderlyingValue().(VarAccess).getName() = name or
2323
actualRead.(DataFlow::PropRead).getPropertyName() = name or
2424
actualRead.(DataFlow::InvokeNode).getCalleeName() = "get" + name
2525
)

0 commit comments

Comments
 (0)