|
4 | 4 | */
|
5 | 5 |
|
6 | 6 | private import codeql.ruby.AST
|
| 7 | +private import codeql.ruby.controlflow.CfgNodes |
7 | 8 | private import codeql.ruby.DataFlow
|
8 | 9 | private import codeql.ruby.TaintTracking
|
9 | 10 | private import codeql.ruby.dataflow.RemoteFlowSources
|
@@ -55,30 +56,30 @@ module MassAssignment {
|
55 | 56 | }
|
56 | 57 |
|
57 | 58 | /** Holds if `h` is an empty hash or contains an empty hash at one if its (possibly nested) values. */
|
58 |
| - private predicate hasEmptyHash(Expr e) { |
59 |
| - e instanceof HashLiteral and |
60 |
| - not exists(e.(HashLiteral).getAKeyValuePair()) |
| 59 | + private predicate hasEmptyHash(ExprCfgNode e) { |
| 60 | + e instanceof ExprNodes::HashLiteralCfgNode and |
| 61 | + not exists(e.(ExprNodes::HashLiteralCfgNode).getAKeyValuePair()) |
61 | 62 | or
|
62 |
| - hasEmptyHash(e.(HashLiteral).getAKeyValuePair().getValue()) |
| 63 | + hasEmptyHash(e.(ExprNodes::HashLiteralCfgNode).getAKeyValuePair().getValue()) |
63 | 64 | or
|
64 |
| - hasEmptyHash(e.(Pair).getValue()) |
| 65 | + hasEmptyHash(e.(ExprNodes::PairCfgNode).getValue()) |
65 | 66 | or
|
66 |
| - hasEmptyHash(e.(ArrayLiteral).getAnElement()) |
| 67 | + hasEmptyHash(e.(ExprNodes::ArrayLiteralCfgNode).getAnArgument()) |
67 | 68 | }
|
68 | 69 |
|
69 | 70 | /** A call to `permit` that fully specifies the permitted parameters. */
|
70 | 71 | private class PermitCallSanitizer extends Sanitizer, DataFlow::CallNode {
|
71 | 72 | PermitCallSanitizer() {
|
72 | 73 | this.getMethodName() = "permit" and
|
73 |
| - not hasEmptyHash(this.getArgument(_).asExpr().getExpr()) |
| 74 | + not hasEmptyHash(this.getArgument(_).getExprNode()) |
74 | 75 | }
|
75 | 76 | }
|
76 | 77 |
|
77 | 78 | /** A call to `permit` that uses an empty hash, which allows arbitrary keys to be specified. */
|
78 | 79 | private class PermitCallMassPermit extends MassPermit instanceof DataFlow::CallNode {
|
79 | 80 | PermitCallMassPermit() {
|
80 | 81 | this.(DataFlow::CallNode).getMethodName() = "permit" and
|
81 |
| - hasEmptyHash(this.(DataFlow::CallNode).getArgument(_).asExpr().getExpr()) |
| 82 | + hasEmptyHash(this.(DataFlow::CallNode).getArgument(_).getExprNode()) |
82 | 83 | }
|
83 | 84 |
|
84 | 85 | override DataFlow::Node getParamsArgument() { result = this.(DataFlow::CallNode).getReceiver() }
|
|
0 commit comments