File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
ruby/ql/src/queries/security/cwe-078 Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ predicate hasConstantPrefix(DataFlow::Node node) {
3737 node .asExpr ( ) .getExpr ( ) .( StringlikeLiteral ) .getComponent ( 0 ) instanceof StringTextComponent
3838 or
3939 // it is not a constant string argument
40- exists ( node .asExpr ( ) . getExpr ( ) . getConstantValue ( ) )
40+ exists ( node .getConstantValue ( ) )
4141 or
4242 // not a concatenation that starts with a constant string
4343 exists ( DataFlow:: ExprNode prefix |
@@ -46,5 +46,13 @@ predicate hasConstantPrefix(DataFlow::Node node) {
4646 )
4747 or
4848 // is a .freeze call on a constant string
49- node .asExpr ( ) .getExpr ( ) .( ConstantReadAccess ) .getValue ( ) .( MethodCall ) .getMethodName ( ) = "freeze"
49+ exists ( DataFlow:: CallNode call | node = call and call .getMethodName ( ) = "freeze" |
50+ hasConstantPrefix ( call .getReceiver ( ) )
51+ )
52+ or
53+ // is a constant read of a constant string
54+ exists ( DataFlow:: Node constant |
55+ constant .asExpr ( ) .getExpr ( ) = node .asExpr ( ) .getExpr ( ) .( ConstantReadAccess ) .getValue ( ) and
56+ hasConstantPrefix ( constant )
57+ )
5058}
You can’t perform that action at this time.
0 commit comments