Skip to content

Commit

Permalink
Ruby: SimpleParameter is not an Expr
Browse files Browse the repository at this point in the history
  • Loading branch information
aibaars committed Dec 16, 2021
1 parent e9ef53c commit cdbd8b2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
7 changes: 6 additions & 1 deletion ruby/ql/lib/codeql/ruby/ast/Erb.qll
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
*/
Stmt getAChildStmt() {
this.containsStmtStart(result) and
not this.containsStmtStart(result.getParent())
not this.containsStmtStart(parent*(result).getParent())
}

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

private AstNode parent(AstNode n) {
result = n.getParent() and
not result instanceof Stmt
}

/**
* A comment directive in an ERB template.
* ```erb
Expand Down
4 changes: 1 addition & 3 deletions ruby/ql/lib/codeql/ruby/ast/Pattern.qll
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ deprecated class Pattern extends AstNode {
Variable getAVariable() { none() }
}

deprecated private class TVariablePattern = TVariableAccess or TSimpleParameter;

/**
* DEPRECATED
*
* A simple variable pattern.
*/
deprecated class VariablePattern extends Pattern, LhsExpr, TVariablePattern {
deprecated class VariablePattern extends Pattern, LhsExpr, TVariableAccess {
override Variable getAVariable() { result = this.(VariableAccess).getVariable() }
}

Expand Down
2 changes: 1 addition & 1 deletion ruby/ql/lib/codeql/ruby/ast/internal/AST.qll
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ class TExpr =
TSelf or TArgumentList or TInClause or TRescueClause or TRescueModifierExpr or TPair or
TStringConcatenation or TCall or TBlockArgument or TConstantAccess or TControlExpr or
TWhenExpr or TLiteral or TCallable or TVariableAccess or TStmtSequence or TOperation or
TSimpleParameter or TForwardArgument or TDestructuredLhsExpr;
TForwardArgument or TDestructuredLhsExpr;

class TSplatExpr = TSplatExprReal or TSplatExprSynth;

Expand Down
2 changes: 1 addition & 1 deletion ruby/ql/lib/codeql/ruby/security/XSS.qll
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private module Shared {
isHelperMethod(helperMethod, name, template) and
isMethodCall(helperMethodCall.getExpr(), name, template) and
helperMethodCall.getArgument(pragma[only_bind_into](argIdx)) = node1.asExpr() and
helperMethod.getParameter(pragma[only_bind_into](argIdx)) = node2.asExpr().getExpr()
helperMethod.getParameter(pragma[only_bind_into](argIdx)) = node2.asParameter()
)
}

Expand Down

0 comments on commit cdbd8b2

Please sign in to comment.