Skip to content

Commit 33cca29

Browse files
committed
drop down to the CFG instead of the AST to better support de-sugaring
1 parent aafef38 commit 33cca29

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ruby/ql/lib/codeql/ruby/frameworks/StringFormatters.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ class StringPercentCall extends PrintfStyleCall {
8787
override DataFlow::Node getFormatString() { result = this.getReceiver() }
8888

8989
override DataFlow::Node getFormatArgument(int n) {
90-
exists(Ast::Call call | call = this.asExpr().getExpr() |
91-
exists(Ast::ArrayLiteral arrLit | arrLit = call.getArgument(0) |
92-
result.asExpr().getExpr() = arrLit.getElement(n)
93-
)
94-
or
95-
exists(Ast::HashLiteral hashLit | hashLit = call.getArgument(0) |
96-
n = -2 and // -2 is indicates that the index does not make sense in this context
97-
result.asExpr().getExpr() = hashLit.getAnElement()
98-
)
90+
exists(CfgNodes::ExprNodes::ArrayLiteralCfgNode arrLit | arrLit = this.getArgument(0).asExpr() |
91+
result.asExpr() = arrLit.getArgument(n)
92+
)
93+
or
94+
exists(CfgNodes::ExprNodes::HashLiteralCfgNode hashLit |
95+
hashLit = this.getArgument(0).asExpr()
96+
|
97+
n = -2 and // -2 is indicates that the index does not make sense in this context
98+
result.asExpr() = hashLit.getAKeyValuePair().getValue()
9999
)
100100
}
101101

0 commit comments

Comments
 (0)