Skip to content

Commit 4cfaa86

Browse files
committed
Ruby: Update new-style barrier-guard
1 parent 5f17d83 commit 4cfaa86

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ruby/ql/lib/codeql/ruby/dataflow/BarrierGuards.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,16 @@ deprecated class StringConstCompare extends DataFlow::BarrierGuard,
8484
}
8585

8686
private predicate stringConstArrayInclusionCall(CfgNodes::ExprCfgNode g, CfgNode e, boolean branch) {
87-
exists(CfgNodes::ExprNodes::MethodCallCfgNode mc, ArrayLiteral aLit |
87+
exists(CfgNodes::ExprNodes::MethodCallCfgNode mc |
8888
mc = g and
8989
mc.getExpr().getMethodName() = "include?" and
90-
[mc.getExpr().getReceiver(), mc.getExpr().getReceiver().(ConstantReadAccess).getValue()] = aLit
91-
|
92-
forall(Expr elem | elem = aLit.getAnElement() | elem instanceof StringLiteral) and
9390
mc.getArgument(0) = e
91+
|
92+
exists(ExprNodes::ArrayLiteralCfgNode arr | isArrayConstant(mc.getReceiver(), arr) |
93+
forall(ExprCfgNode elem | elem = arr.getAnArgument() |
94+
elem instanceof ExprNodes::StringLiteralCfgNode
95+
)
96+
)
9497
) and
9598
branch = true
9699
}

0 commit comments

Comments
 (0)