@@ -28,7 +28,7 @@ module Zip {
28
28
}
29
29
30
30
/**
31
- * input in following
31
+ * An input in following
32
32
* ```ruby
33
33
* input = ip::InputStream.open(path)
34
34
* Zip::InputStream.open(path) do |input|
@@ -38,7 +38,7 @@ module Zip {
38
38
*/
39
39
private API:: Node instance ( ) {
40
40
result =
41
- [ zipInputStream ( ) .getMethod ( "open" ) .( GetReturnOrGetBlock ) .getReturnOrGetBlockParameter ( ) ]
41
+ zipInputStream ( ) .getMethod ( "open" ) .( GetReturnOrGetBlock ) .getReturnOrGetBlockParameter ( )
42
42
}
43
43
44
44
predicate isAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
@@ -59,7 +59,7 @@ module Zip {
59
59
}
60
60
61
61
DataFlow:: Node isSink ( ) {
62
- exists ( string ioMethods | not ioMethods = [ "get_next_entry" ] |
62
+ exists ( string ioMethods | not ioMethods = "get_next_entry" |
63
63
result = instance ( ) .getMethod ( ioMethods ) .getReturn ( ) .asSource ( )
64
64
)
65
65
}
@@ -104,12 +104,7 @@ module Zip {
104
104
*/
105
105
API:: Node instance ( ) {
106
106
result =
107
- [
108
- zipFile ( )
109
- .getMethod ( [ "open" , "new" ] )
110
- .( GetReturnOrGetBlock )
111
- .getReturnOrGetBlockParameter ( )
112
- ]
107
+ zipFile ( ) .getMethod ( [ "open" , "new" ] ) .( GetReturnOrGetBlock ) .getReturnOrGetBlockParameter ( )
113
108
}
114
109
115
110
/**
@@ -189,14 +184,6 @@ module Zip {
189
184
* # Find specific entry with Zip::File.open(zipfile_path).glob(pattern)
190
185
*/
191
186
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
-
200
187
/**
201
188
* `extract` and `read` can be sink
202
189
* ```ruby
@@ -242,14 +229,12 @@ module Zip {
242
229
exists ( API:: Node zipFileOpen | zipFileOpen = zipFile ( ) .getMethod ( [ "open" , "new" ] ) |
243
230
nodeFrom = zipFileOpen .getParameter ( 0 ) .asSink ( ) and
244
231
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 ( ) )
253
238
)
254
239
}
255
240
}
@@ -259,38 +244,6 @@ module Zip {
259
244
*/
260
245
private API:: Node zipFile ( ) { result = API:: getTopLevelMember ( "Zip" ) .getMember ( "File" ) }
261
246
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
-
294
247
DataFlow:: Node isAdditionalTaintStepHelper ( API:: Node nodeMiddle ) {
295
248
result = nodeMiddle .getMethod ( _) .getReturn ( ) .asSource ( ) or
296
249
result = nodeMiddle .getMethod ( _) .getReturn ( ) .getMethod ( _) .getReturn ( ) .asSource ( )
@@ -324,7 +277,7 @@ module Zlib {
324
277
]
325
278
}
326
279
327
- API:: Node gzipReaderNew ( ) { result = [ gzipReaderInstance ( ) .getMethod ( "new" ) .getReturn ( ) ] }
280
+ API:: Node gzipReaderNew ( ) { result = gzipReaderInstance ( ) .getMethod ( "new" ) .getReturn ( ) }
328
281
329
282
/**
330
283
* `entry` and `read` can be sink
@@ -361,7 +314,7 @@ module Zlib {
361
314
.getParameter ( 0 )
362
315
.asSource ( )
363
316
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
365
318
exists ( string ioMethods | not ioMethods = [ "glob" , "each" , "each_entry" ] |
366
319
result = gzipReaderNew ( ) .getMethod ( ioMethods ) .getReturn ( ) .asSource ( ) or
367
320
result = gzipReaderOpen ( ) .getMethod ( ioMethods ) .getReturn ( ) .asSource ( )
@@ -464,6 +417,7 @@ class Bombs extends TaintTracking::Configuration {
464
417
nodeTo = n .getReturn ( ) .asSource ( )
465
418
)
466
419
or
420
+ // following can be a global additional step
467
421
exists ( DataFlow:: CallNode cn |
468
422
cn .getMethodName ( ) = "open" and cn .getReceiver ( ) .toString ( ) = "self"
469
423
|
0 commit comments