@@ -6,6 +6,7 @@ private import codeql.ruby.CFG
66private import codeql.ruby.controlflow.CfgNodes
77private import codeql.ruby.dataflow.SSA
88private import codeql.ruby.ast.internal.Constant
9+ private import codeql.ruby.InclusionTests
910
1011private predicate stringConstCompare ( CfgNodes:: ExprCfgNode g , CfgNode e , boolean branch ) {
1112 exists ( CfgNodes:: ExprNodes:: ComparisonOperationCfgNode c |
@@ -72,18 +73,19 @@ deprecated class StringConstCompare extends DataFlow::BarrierGuard,
7273}
7374
7475private predicate stringConstArrayInclusionCall ( CfgNodes:: ExprCfgNode g , CfgNode e , boolean branch ) {
75- exists ( CfgNodes :: ExprNodes :: MethodCallCfgNode mc |
76- mc = g and
77- mc . getExpr ( ) .getMethodName ( ) = "include?" and
78- mc . getArgument ( 0 ) = e
76+ exists ( InclusionTest t |
77+ t . asExpr ( ) = g and
78+ e = t . getContainedNode ( ) .asExpr ( ) and
79+ branch = t . getPolarity ( )
7980 |
80- exists ( ExprNodes:: ArrayLiteralCfgNode arr | isArrayConstant ( mc .getReceiver ( ) , arr ) |
81+ exists ( ExprNodes:: ArrayLiteralCfgNode arr |
82+ isArrayConstant ( t .getContainerNode ( ) .asExpr ( ) , arr )
83+ |
8184 forall ( ExprCfgNode elem | elem = arr .getAnArgument ( ) |
8285 elem instanceof ExprNodes:: StringLiteralCfgNode
8386 )
8487 )
85- ) and
86- branch = true
88+ )
8789}
8890
8991/**
@@ -126,7 +128,7 @@ deprecated class StringConstArrayInclusionCall extends DataFlow::BarrierGuard,
126128 CfgNodes:: ExprNodes:: MethodCallCfgNode {
127129 private CfgNode checkedNode ;
128130
129- StringConstArrayInclusionCall ( ) { stringConstArrayInclusionCall ( this , checkedNode , _ ) }
131+ StringConstArrayInclusionCall ( ) { stringConstArrayInclusionCall ( this , checkedNode , true ) }
130132
131133 override predicate checks ( CfgNode expr , boolean branch ) { expr = checkedNode and branch = true }
132134}
0 commit comments