diff --git a/ql/src/codeql_ruby/ast/Operation.qll b/ql/src/codeql_ruby/ast/Operation.qll index 3544a9dd3f4..1b2458777f5 100644 --- a/ql/src/codeql_ruby/ast/Operation.qll +++ b/ql/src/codeql_ruby/ast/Operation.qll @@ -445,10 +445,10 @@ class Assignment extends Operation { override Assignment::Range range; /** Gets the left hand side of this assignment. */ - final Expr getLhs() { result = range.getLhs() } + final Expr getLeftOperand() { result = range.getLeftOperand() } /** Gets the right hand side of this assignment. */ - final Expr getRhs() { result = range.getRhs() } + final Expr getRightOperand() { result = range.getRightOperand() } } /** diff --git a/ql/src/codeql_ruby/ast/Variable.qll b/ql/src/codeql_ruby/ast/Variable.qll index 0159c63b6f0..6f283d813ed 100644 --- a/ql/src/codeql_ruby/ast/Variable.qll +++ b/ql/src/codeql_ruby/ast/Variable.qll @@ -156,7 +156,7 @@ class VariableReadAccess extends VariableAccess { not this instanceof VariableWriteAccess or // `x` in `x += y` is considered both a read and a write - this = any(AssignOperation a).getLhs() + this = any(AssignOperation a).getLeftOperand() } } diff --git a/ql/src/codeql_ruby/ast/internal/Operation.qll b/ql/src/codeql_ruby/ast/internal/Operation.qll index 0a0715961f3..c55af802ef8 100644 --- a/ql/src/codeql_ruby/ast/internal/Operation.qll +++ b/ql/src/codeql_ruby/ast/internal/Operation.qll @@ -218,11 +218,13 @@ module NoRegexMatchExpr { module Assignment { abstract class Range extends Operation::Range { - abstract Expr getLhs(); + abstract Pattern getLeftOperand(); - abstract Expr getRhs(); + abstract Expr getRightOperand(); - final override Expr getAnOperand() { result = this.getLhs() or result = this.getRhs() } + final override Expr getAnOperand() { + result = this.getLeftOperand() or result = this.getRightOperand() + } override string toString() { result = "... " + this.getOperator() + " ..." } } @@ -232,9 +234,9 @@ module AssignExpr { class Range extends Assignment::Range, @assignment { final override Generated::Assignment generated; - final override Expr getLhs() { result = generated.getLeft() } + final override Pattern getLeftOperand() { result = generated.getLeft() } - final override Expr getRhs() { result = generated.getRight() } + final override Expr getRightOperand() { result = generated.getRight() } final override string getOperator() { result = "=" } } @@ -246,9 +248,9 @@ module AssignOperation { final override string getOperator() { result = generated.getOperator() } - final override LhsExpr getLhs() { result = generated.getLeft() } + final override LhsExpr getLeftOperand() { result = generated.getLeft() } - final override Expr getRhs() { result = generated.getRight() } + final override Expr getRightOperand() { result = generated.getRight() } } } diff --git a/ql/src/codeql_ruby/controlflow/CfgNodes.qll b/ql/src/codeql_ruby/controlflow/CfgNodes.qll index 58b0bf717df..2258f02c28b 100644 --- a/ql/src/codeql_ruby/controlflow/CfgNodes.qll +++ b/ql/src/codeql_ruby/controlflow/CfgNodes.qll @@ -218,10 +218,10 @@ module ExprNodes { final override Assignment getExpr() { result = ExprCfgNode.super.getExpr() } /** Gets the LHS of this assignment. */ - final ExprCfgNode getLhs() { e.hasCfgChild(e.getLhs(), this, result) } + final ExprCfgNode getLhs() { e.hasCfgChild(e.getLeftOperand(), this, result) } /** Gets the RHS of this assignment. */ - final ExprCfgNode getRhs() { e.hasCfgChild(e.getRhs(), this, result) } + final ExprCfgNode getRhs() { e.hasCfgChild(e.getRightOperand(), this, result) } } /** A control-flow node that wraps an `AssignExpr` AST expression. */ diff --git a/ql/test/library-tests/ast/operations/assignment.ql b/ql/test/library-tests/ast/operations/assignment.ql index 83828da3ce7..3ff3b3f7684 100644 --- a/ql/test/library-tests/ast/operations/assignment.ql +++ b/ql/test/library-tests/ast/operations/assignment.ql @@ -2,8 +2,8 @@ import ruby query predicate assignments(Assignment a, string operator, Expr left, Expr right, string pClass) { operator = a.getOperator() and - left = a.getLhs() and - right = a.getRhs() and + left = a.getLeftOperand() and + right = a.getRightOperand() and pClass = a.getAPrimaryQlClass() } @@ -11,8 +11,8 @@ query predicate assignOperations( AssignOperation o, string operator, Expr left, Expr right, string pClass ) { operator = o.getOperator() and - left = o.getLhs() and - right = o.getRhs() and + left = o.getLeftOperand() and + right = o.getRightOperand() and pClass = o.getAPrimaryQlClass() }