Skip to content

Commit cdbd8b2

Browse files
committed
Ruby: SimpleParameter is not an Expr
1 parent e9ef53c commit cdbd8b2

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

ruby/ql/lib/codeql/ruby/ast/Erb.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
159159
*/
160160
Stmt getAChildStmt() {
161161
this.containsStmtStart(result) and
162-
not this.containsStmtStart(result.getParent())
162+
not this.containsStmtStart(parent*(result).getParent())
163163
}
164164

165165
/**
@@ -183,6 +183,11 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
183183
override string getAPrimaryQlClass() { result = "ErbDirective" }
184184
}
185185

186+
private AstNode parent(AstNode n) {
187+
result = n.getParent() and
188+
not result instanceof Stmt
189+
}
190+
186191
/**
187192
* A comment directive in an ERB template.
188193
* ```erb

ruby/ql/lib/codeql/ruby/ast/Pattern.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ deprecated class Pattern extends AstNode {
2828
Variable getAVariable() { none() }
2929
}
3030

31-
deprecated private class TVariablePattern = TVariableAccess or TSimpleParameter;
32-
3331
/**
3432
* DEPRECATED
3533
*
3634
* A simple variable pattern.
3735
*/
38-
deprecated class VariablePattern extends Pattern, LhsExpr, TVariablePattern {
36+
deprecated class VariablePattern extends Pattern, LhsExpr, TVariableAccess {
3937
override Variable getAVariable() { result = this.(VariableAccess).getVariable() }
4038
}
4139

ruby/ql/lib/codeql/ruby/ast/internal/AST.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ class TExpr =
660660
TSelf or TArgumentList or TInClause or TRescueClause or TRescueModifierExpr or TPair or
661661
TStringConcatenation or TCall or TBlockArgument or TConstantAccess or TControlExpr or
662662
TWhenExpr or TLiteral or TCallable or TVariableAccess or TStmtSequence or TOperation or
663-
TSimpleParameter or TForwardArgument or TDestructuredLhsExpr;
663+
TForwardArgument or TDestructuredLhsExpr;
664664

665665
class TSplatExpr = TSplatExprReal or TSplatExprSynth;
666666

ruby/ql/lib/codeql/ruby/security/XSS.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private module Shared {
227227
isHelperMethod(helperMethod, name, template) and
228228
isMethodCall(helperMethodCall.getExpr(), name, template) and
229229
helperMethodCall.getArgument(pragma[only_bind_into](argIdx)) = node1.asExpr() and
230-
helperMethod.getParameter(pragma[only_bind_into](argIdx)) = node2.asExpr().getExpr()
230+
helperMethod.getParameter(pragma[only_bind_into](argIdx)) = node2.asParameter()
231231
)
232232
}
233233

0 commit comments

Comments
 (0)