File tree Expand file tree Collapse file tree 2 files changed +17
-23
lines changed Expand file tree Collapse file tree 2 files changed +17
-23
lines changed Original file line number Diff line number Diff line change @@ -38,21 +38,25 @@ private class YamlParseStep extends AdditionalTaintStep {
38
38
)
39
39
)
40
40
or
41
- exists ( API:: Node yamlParserMethod |
41
+ exists ( API:: Node parseSuccessors | parseSuccessors = yamlParseChildNodeAccess ( _ ) |
42
42
succ =
43
43
[
44
- yamlParserMethod .getASuccessor * ( ) .getMethod ( "to_ruby" ) .getReturn ( ) .asSource ( ) ,
45
- yamlParserMethod
46
- .getASuccessor * ( )
47
- .getMethod ( "to_ruby" )
48
- .getReturn ( )
49
- .getAnElement ( )
50
- .asSource ( )
44
+ parseSuccessors .getMethod ( "to_ruby" ) .getReturn ( ) .asSource ( ) ,
45
+ parseSuccessors .getMethod ( "to_ruby" ) .getReturn ( ) .getAnElement ( ) .asSource ( )
51
46
] and
52
- yamlParserMethod = yamlNode ( ) .getMethod ( [ "parse" , "parse_stream" , "parse_file" ] ) and
53
- pred = yamlParserMethod .getReturn ( ) .asSource ( )
47
+ pred = parseSuccessors .asSource ( )
54
48
)
55
49
}
56
50
}
57
51
52
+ API:: Node yamlParseChildNodeAccess ( API:: Node source ) {
53
+ source = yamlNode ( ) .getMethod ( [ "parse" , "parse_stream" ] ) .getReturn ( ) and source = result
54
+ or
55
+ result = yamlParseChildNodeAccess ( source ) .getMethod ( _) .getReturn ( )
56
+ or
57
+ result = yamlParseChildNodeAccess ( source ) .getMethod ( _) .getBlock ( ) .getParameter ( _)
58
+ or
59
+ result = yamlParseChildNodeAccess ( source ) .getAnElement ( )
60
+ }
61
+
58
62
private API:: Node yamlNode ( ) { result = API:: getTopLevelMember ( [ "YAML" , "Psych" ] ) }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ private import codeql.ruby.dataflow.RemoteFlowSources
11
11
private import codeql.ruby.frameworks.ActiveJob
12
12
private import codeql.ruby.frameworks.core.Module
13
13
private import codeql.ruby.frameworks.core.Kernel
14
+ private import codeql.ruby.frameworks.Yaml
14
15
15
16
module UnsafeDeserialization {
16
17
/**
@@ -103,19 +104,8 @@ module UnsafeDeserialization {
103
104
YamlParseArgument ( ) {
104
105
this =
105
106
[
106
- yamlNode ( )
107
- .getMethod ( [ "parse" , "parse_stream" , "parse_file" ] )
108
- .getASuccessor * ( )
109
- .getMethod ( "to_ruby" )
110
- .getReturn ( )
111
- .asSource ( ) ,
112
- yamlNode ( )
113
- .getMethod ( [ "parse" , "parse_stream" , "parse_file" ] )
114
- .getASuccessor * ( )
115
- .getMethod ( "to_ruby" )
116
- .getReturn ( )
117
- .getAnElement ( )
118
- .asSource ( )
107
+ yamlParseChildNodeAccess ( _) .getMethod ( "to_ruby" ) .getReturn ( ) .asSource ( ) ,
108
+ yamlParseChildNodeAccess ( _) .getMethod ( "to_ruby" ) .getReturn ( ) .getAnElement ( ) .asSource ( )
119
109
]
120
110
}
121
111
}
You can’t perform that action at this time.
0 commit comments