@@ -6,6 +6,7 @@ private import ruby
6
6
private import codeql.ruby.dataflow.RemoteFlowSources
7
7
private import codeql.ruby.Concepts
8
8
private import codeql.ruby.TaintTracking
9
+ private import codeql.ruby.ApiGraphs
9
10
import UnicodeBypassValidationCustomizations:: UnicodeBypassValidation
10
11
11
12
/** A state signifying that a logical validation has not been performed. */
@@ -39,8 +40,40 @@ class Configuration extends TaintTracking::Configuration {
39
40
exists ( Escaping escaping | nodeFrom = escaping .getAnInput ( ) and nodeTo = escaping .getOutput ( ) )
40
41
or
41
42
exists ( RegexExecution re | nodeFrom = re .getString ( ) and nodeTo = re )
42
- // or
43
- // stringManipulation(nodeFrom, nodeTo)
43
+ or
44
+ // String Manipulation Method Calls
45
+ // https://ruby-doc.org/core-2.7.0/String.html
46
+ exists ( DataFlow:: CallNode cn |
47
+ cn .getMethodName ( ) =
48
+ [
49
+ [
50
+ "ljust" , "lstrip" , "succ" , "next" , "rjust" , "capitalize" , "chomp" , "gsub" , "chop" ,
51
+ "downcase" , "swapcase" , "uprcase" , "scrub" , "slice" , "squeeze" , "strip" , "sub" ,
52
+ "tr" , "tr_s" , "reverse"
53
+ ] + [ "" , "!" ] , "concat" , "dump" , "each_line" , "replace" , "insert" , "inspect" , "lines" ,
54
+ "partition" , "prepend" , "replace" , "rpartition" , "scan" , "split" , "undump" ,
55
+ "unpack" + [ "" , "1" ]
56
+ ] and
57
+ nodeFrom = cn .getReceiver ( ) and
58
+ nodeTo = cn
59
+ )
60
+ or
61
+ exists ( DataFlow:: CallNode cn |
62
+ cn .getMethodName ( ) =
63
+ [
64
+ "casecmp" + [ "" , "?" ] , "center" , "count" , "each_char" , "index" , "rindex" , "sum" ,
65
+ [ "delete" , "delete_prefix" , "delete_suffix" ] + [ "" , "!" ] ,
66
+ [ "start_with" , "end_with" + "eql" , "include" ] + [ "?" , "!" ] , "match" + [ "" , "?" ] ,
67
+ ] and
68
+ nodeFrom = cn .getReceiver ( ) and
69
+ nodeTo = nodeFrom
70
+ )
71
+ or
72
+ exists ( DataFlow:: CallNode cn |
73
+ cn = API:: getTopLevelMember ( "CGI" ) .getAMethodCall ( "escapeHTML" ) and
74
+ nodeFrom = cn .getArgument ( 0 ) and
75
+ nodeTo = cn
76
+ )
44
77
) and
45
78
stateFrom instanceof PreValidation and
46
79
stateTo instanceof PostValidation
0 commit comments