mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
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:
@@ -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)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user