1
1
private import codeql.ruby.Regexp
2
- private import codeql.ruby.ast.Literal as Ast
2
+ private import codeql.ruby.AST as Ast
3
+ private import codeql.ruby.CFG
3
4
private import codeql.ruby.DataFlow
4
5
private import codeql.ruby.controlflow.CfgNodes
5
- private import codeql.ruby.dataflow.internal.tainttrackingforregexp.TaintTrackingImpl
6
+ private import codeql.ruby.dataflow.internal.DataFlowImplForRegExp
6
7
private import codeql.ruby.typetracking.TypeTracker
7
8
private import codeql.ruby.ApiGraphs
8
9
private import codeql.ruby.dataflow.internal.DataFlowPrivate as DataFlowPrivate
@@ -24,7 +25,7 @@ class RegExpConfiguration extends Configuration {
24
25
25
26
override predicate isSink ( DataFlow:: Node sink ) { sink instanceof RegExpInterpretation:: Range }
26
27
27
- override predicate isSanitizer ( DataFlow:: Node node ) {
28
+ override predicate isBarrier ( DataFlow:: Node node ) {
28
29
exists ( DataFlow:: CallNode mce | mce .getMethodName ( ) = [ "match" , "match?" ] |
29
30
// receiver of https://ruby-doc.org/core-2.4.0/String.html#method-i-match
30
31
node = mce .getReceiver ( ) and
@@ -34,11 +35,24 @@ class RegExpConfiguration extends Configuration {
34
35
node = mce .getArgument ( 0 ) and
35
36
mce .getReceiver ( ) = trackRegexpType ( )
36
37
)
37
- or
38
- // only include taint flow through `String` summaries
39
- FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( _, node , false ) and
40
- not node .( DataFlowPrivate:: SummaryNode ) .getSummarizedCallable ( ) instanceof
38
+ }
39
+
40
+ override predicate isAdditionalFlowStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
41
+ // include taint flow through `String` summaries,
42
+ FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom , nodeTo , false ) and
43
+ nodeFrom .( DataFlowPrivate:: SummaryNode ) .getSummarizedCallable ( ) instanceof
41
44
String:: SummarizedCallable
45
+ or
46
+ // string concatenations, and
47
+ exists ( CfgNodes:: ExprNodes:: OperationCfgNode op |
48
+ op = nodeTo .asExpr ( ) and
49
+ op .getAnOperand ( ) = nodeFrom .asExpr ( ) and
50
+ op .getExpr ( ) .( Ast:: BinaryOperation ) .getOperator ( ) = "+"
51
+ )
52
+ or
53
+ // string interpolations
54
+ nodeFrom .asExpr ( ) =
55
+ nodeTo .asExpr ( ) .( CfgNodes:: ExprNodes:: StringlikeLiteralCfgNode ) .getAComponent ( )
42
56
}
43
57
}
44
58
0 commit comments