@@ -28,7 +28,7 @@ module Zip {
2828 }
2929
3030 /**
31- * input in following
31+ * An input in following
3232 * ```ruby
3333 * input = ip::InputStream.open(path)
3434 * Zip::InputStream.open(path) do |input|
@@ -38,7 +38,7 @@ module Zip {
3838 */
3939 private API:: Node instance ( ) {
4040 result =
41- [ zipInputStream ( ) .getMethod ( "open" ) .( GetReturnOrGetBlock ) .getReturnOrGetBlockParameter ( ) ]
41+ zipInputStream ( ) .getMethod ( "open" ) .( GetReturnOrGetBlock ) .getReturnOrGetBlockParameter ( )
4242 }
4343
4444 predicate isAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
@@ -59,7 +59,7 @@ module Zip {
5959 }
6060
6161 DataFlow:: Node isSink ( ) {
62- exists ( string ioMethods | not ioMethods = [ "get_next_entry" ] |
62+ exists ( string ioMethods | not ioMethods = "get_next_entry" |
6363 result = instance ( ) .getMethod ( ioMethods ) .getReturn ( ) .asSource ( )
6464 )
6565 }
@@ -104,12 +104,7 @@ module Zip {
104104 */
105105 API:: Node instance ( ) {
106106 result =
107- [
108- zipFile ( )
109- .getMethod ( [ "open" , "new" ] )
110- .( GetReturnOrGetBlock )
111- .getReturnOrGetBlockParameter ( )
112- ]
107+ zipFile ( ) .getMethod ( [ "open" , "new" ] ) .( GetReturnOrGetBlock ) .getReturnOrGetBlockParameter ( )
113108 }
114109
115110 /**
@@ -189,14 +184,6 @@ module Zip {
189184 * # Find specific entry with Zip::File.open(zipfile_path).glob(pattern)
190185 */
191186 module Glob {
192- API:: Node instance ( ) {
193- result =
194- [
195- zipFile ( ) .getMethod ( [ "open" , "new" ] ) .getReturn ( ) .getMethod ( "glob" ) ,
196- zipFile ( ) .getMethod ( [ "open" , "new" ] ) .getBlock ( ) .getParameter ( 0 ) .getMethod ( "glob" )
197- ]
198- }
199-
200187 /**
201188 * `extract` and `read` can be sink
202189 * ```ruby
@@ -242,14 +229,12 @@ module Zip {
242229 exists ( API:: Node zipFileOpen | zipFileOpen = zipFile ( ) .getMethod ( [ "open" , "new" ] ) |
243230 nodeFrom = zipFileOpen .getParameter ( 0 ) .asSink ( ) and
244231 nodeTo =
245- [
246- isAdditionalTaintStepHelper ( zipFileOpen
247- .( GetReturnOrGetBlock )
248- .getReturnOrGetBlockParameter ( )
249- .getMethod ( "glob" )
250- .( GetReturnOrGetBlock )
251- .getReturnOrGetBlockParameter ( ) )
252- ]
232+ isAdditionalTaintStepHelper ( zipFileOpen
233+ .( GetReturnOrGetBlock )
234+ .getReturnOrGetBlockParameter ( )
235+ .getMethod ( "glob" )
236+ .( GetReturnOrGetBlock )
237+ .getReturnOrGetBlockParameter ( ) )
253238 )
254239 }
255240 }
@@ -259,38 +244,6 @@ module Zip {
259244 */
260245 private API:: Node zipFile ( ) { result = API:: getTopLevelMember ( "Zip" ) .getMember ( "File" ) }
261246
262- /**
263- * ```ruby
264- * returun = inputNode do
265- * returun.each do |entry|
266- * outputnode = entry
267- * end
268- * ```
269- */
270- API:: Node oneBlockParameter ( API:: Node nodeMiddle ) {
271- result =
272- nodeMiddle .getReturn ( ) .getMethod ( [ "each" , "each_entry" , "first" ] ) .getBlock ( ) .getParameter ( 0 )
273- }
274-
275- /**
276- * ```ruby
277- * inputNode do |param|
278- * param.each do |entry|
279- * outputnode = entry
280- * end
281- * end
282- * ```
283- */
284- API:: Node twoBlockParameter ( API:: Node nodeMiddle ) {
285- result =
286- nodeMiddle
287- .getBlock ( )
288- .getParameter ( 0 )
289- .getMethod ( [ "each" , "each_entry" , "first" ] )
290- .getBlock ( )
291- .getParameter ( 0 )
292- }
293-
294247 DataFlow:: Node isAdditionalTaintStepHelper ( API:: Node nodeMiddle ) {
295248 result = nodeMiddle .getMethod ( _) .getReturn ( ) .asSource ( ) or
296249 result = nodeMiddle .getMethod ( _) .getReturn ( ) .getMethod ( _) .getReturn ( ) .asSource ( )
@@ -324,7 +277,7 @@ module Zlib {
324277 ]
325278 }
326279
327- API:: Node gzipReaderNew ( ) { result = [ gzipReaderInstance ( ) .getMethod ( "new" ) .getReturn ( ) ] }
280+ API:: Node gzipReaderNew ( ) { result = gzipReaderInstance ( ) .getMethod ( "new" ) .getReturn ( ) }
328281
329282 /**
330283 * `entry` and `read` can be sink
@@ -361,7 +314,7 @@ module Zlib {
361314 .getParameter ( 0 )
362315 .asSource ( )
363316 or
364- // _ is one of ["read", "readlines", "readpartial", "readline", "gets"] and more because gzipReader return an IO instance, there are alot of methods and gzipReader is for reading gzip files, so there is low FP rate here if we use _ instead of exact IO method names
317+ // _ is one of ["read", "readlines", "readpartial", "readline", "gets"] and more because gzipReader return an IO instance, there are a lot of methods and gzipReader is for reading gzip files, so there is low FP rate here if we use _ instead of exact IO method names
365318 exists ( string ioMethods | not ioMethods = [ "glob" , "each" , "each_entry" ] |
366319 result = gzipReaderNew ( ) .getMethod ( ioMethods ) .getReturn ( ) .asSource ( ) or
367320 result = gzipReaderOpen ( ) .getMethod ( ioMethods ) .getReturn ( ) .asSource ( )
@@ -464,6 +417,7 @@ class Bombs extends TaintTracking::Configuration {
464417 nodeTo = n .getReturn ( ) .asSource ( )
465418 )
466419 or
420+ // following can be a global additional step
467421 exists ( DataFlow:: CallNode cn |
468422 cn .getMethodName ( ) = "open" and cn .getReceiver ( ) .toString ( ) = "self"
469423 |
0 commit comments