Skip to content

Commit 96aef9f

Browse files
authored
Merge pull request #7393 from aibaars/ruby-simple-parameter-not-expr
Ruby: SimpleParameter should not be an Expr
2 parents 734bfbd + 3ef707e commit 96aef9f

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private class ErbDirectiveFile extends File {
118118

119119
/** Gets a statement in this file. */
120120
pragma[nomagic]
121-
Stmt getAStmt(int startLine, int startColumn) {
121+
AstNode getAnAstNode(int startLine, int startColumn) {
122122
exists(Location loc |
123123
result.getLocation() = loc and
124124
loc.getFile() = this and
@@ -142,13 +142,13 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
142142
)
143143
}
144144

145-
private predicate containsStmtStart(Stmt s) {
145+
private predicate containsAstNodeStart(AstNode s) {
146146
// `Toplevel` statements are not contained within individual directives,
147147
// though their start location may appear within a directive location
148148
not s instanceof Toplevel and
149149
exists(ErbDirectiveFile file, int startLine, int startColumn |
150150
this.spans(file, startLine) and
151-
s = file.getAStmt(startLine, startColumn) and
151+
s = file.getAnAstNode(startLine, startColumn) and
152152
locationIncludesPosition(this.getLocation(), startLine, startColumn)
153153
)
154154
}
@@ -158,8 +158,8 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
158158
* statement starting in this directive.
159159
*/
160160
Stmt getAChildStmt() {
161-
this.containsStmtStart(result) and
162-
not this.containsStmtStart(result.getParent())
161+
this.containsAstNodeStart(result) and
162+
not this.containsAstNodeStart(result.getParent())
163163
}
164164

165165
/**

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)