mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
JS: replace .stripParens query uses w. .getUnderlyingReference
This commit is contained in:
@@ -65,7 +65,7 @@ predicate maybeNegativeVar(Variable v) {
|
||||
// is v ever assigned a potentially negative value?
|
||||
maybeNegative(v.getAnAssignedExpr()) or
|
||||
// is v ever decremented?
|
||||
exists (DecExpr dec | dec.getOperand().stripParens() = v.getAnAccess()) or
|
||||
exists (DecExpr dec | dec.getOperand().getUnderlyingReference() = v.getAnAccess()) or
|
||||
// is v ever subject to a compound assignment other than +=, or to
|
||||
// += with potentially negative rhs?
|
||||
exists (CompoundAssignExpr assgn | assgn.getTarget() = v.getAnAccess() |
|
||||
|
||||
@@ -26,7 +26,7 @@ class IncrementExpr extends Expr {
|
||||
// x = x + e
|
||||
exists (AssignExpr assgn, Variable v | assgn = this |
|
||||
assgn.getTarget() = v.getAnAccess() and
|
||||
assgn.getRhs().(AddExpr).getAnOperand().stripParens() = v.getAnAccess()
|
||||
assgn.getRhs().(AddExpr).getAnOperand().getUnderlyingReference() = v.getAnAccess()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import semmle.javascript.dataflow.Refinements
|
||||
*/
|
||||
predicate isDefensiveInit(VarAccess va) {
|
||||
exists (LogOrExpr o, VarRef va2 |
|
||||
va = o.getLeftOperand().stripParens() and va2.getVariable() = va.getVariable() |
|
||||
va = o.getLeftOperand().getUnderlyingReference() and va2.getVariable() = va.getVariable() |
|
||||
exists (AssignExpr assgn | va2 = assgn.getTarget() |
|
||||
assgn = o.getRightOperand().stripParens() or
|
||||
o = assgn.getRhs().getUnderlyingValue()
|
||||
|
||||
@@ -19,7 +19,7 @@ private import Declarations.Declarations
|
||||
* `x` has kind `"V"`.
|
||||
*/
|
||||
string refKind(RefExpr r) {
|
||||
if exists(InvokeExpr invk | r = invk.getCallee().stripParens()) then
|
||||
if exists(InvokeExpr invk | r = invk.getCallee().getUnderlyingReference()) then
|
||||
result = "M"
|
||||
else
|
||||
result = "V"
|
||||
@@ -143,7 +143,7 @@ predicate typedInvokeLookup(ASTNode ref, ASTNode decl, string kind) {
|
||||
not variableDefLookup(ref, decl, _) and
|
||||
not propertyLookup(ref, decl, _) and
|
||||
exists (InvokeExpr invoke, Expr callee |
|
||||
callee = invoke.getCallee().stripParens() and
|
||||
callee = invoke.getCallee().getUnderlyingReference() and
|
||||
(ref = callee.(Identifier) or ref = callee.(DotExpr).getPropertyNameExpr()) and
|
||||
decl = invoke.getResolvedCallee() and
|
||||
kind = "M")
|
||||
|
||||
Reference in New Issue
Block a user