Ruby: improve non-constant-kernel-open, recursive step for freeze

Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
This commit is contained in:
Peter Stöckli
2023-04-19 10:50:59 +02:00
committed by GitHub
parent 2f268b309b
commit 672cb92fbd

View File

@@ -37,7 +37,7 @@ predicate hasConstantPrefix(DataFlow::Node node) {
node.asExpr().getExpr().(StringlikeLiteral).getComponent(0) instanceof StringTextComponent node.asExpr().getExpr().(StringlikeLiteral).getComponent(0) instanceof StringTextComponent
or or
// it is not a constant string argument // it is not a constant string argument
exists(node.asExpr().getExpr().getConstantValue()) exists(node.getConstantValue())
or or
// not a concatenation that starts with a constant string // not a concatenation that starts with a constant string
exists(DataFlow::ExprNode prefix | exists(DataFlow::ExprNode prefix |
@@ -46,5 +46,13 @@ predicate hasConstantPrefix(DataFlow::Node node) {
) )
or or
// is a .freeze call on a constant string // is a .freeze call on a constant string
node.asExpr().getExpr().(ConstantReadAccess).getValue().(MethodCall).getMethodName() = "freeze" exists(DataFlow::CallNode call | node = call and call.getMethodName() = "freeze" |
hasConstantPrefix(call.getReceiver())
)
or
// is a constant read of a constant string
exists(DataFlow::Node constant |
constant.asExpr().getExpr() = node.asExpr().getExpr().(ConstantReadAccess).getValue() and
hasConstantPrefix(constant)
)
} }