@@ -17,6 +17,22 @@ module DecompressionBomb {
17
17
class AdditionalStep extends Unit {
18
18
abstract predicate step ( DataFlow:: Node n1 , DataFlow:: Node n2 ) ;
19
19
}
20
+
21
+ abstract class BombReadInputStreamCall extends MethodCall { }
22
+
23
+ private class ReadInputStreamQualifierSink extends DecompressionBomb:: Sink {
24
+ ReadInputStreamQualifierSink ( ) { this .asExpr ( ) = any ( BombReadInputStreamCall r ) .getQualifier ( ) }
25
+ }
26
+
27
+ abstract class BombTypeInputStream extends RefType { }
28
+
29
+ private class TypeInputStreamConstructorArgumentSink extends DecompressionBomb:: Sink {
30
+ TypeInputStreamConstructorArgumentSink ( ) {
31
+ exists ( ConstructorCall call | call .getConstructedType ( ) instanceof BombTypeInputStream |
32
+ this .asExpr ( ) = call .getArgument ( 0 )
33
+ )
34
+ }
35
+ }
20
36
}
21
37
22
38
/**
@@ -26,7 +42,7 @@ module XerialSnappy {
26
42
/**
27
43
* A type that is responsible for `SnappyInputStream` Class
28
44
*/
29
- class TypeInputStream extends RefType {
45
+ class TypeInputStream extends DecompressionBomb :: BombTypeInputStream {
30
46
TypeInputStream ( ) {
31
47
this .getASupertype * ( ) .hasQualifiedName ( "org.xerial.snappy" , "SnappyInputStream" )
32
48
}
@@ -35,7 +51,7 @@ module XerialSnappy {
35
51
/**
36
52
* The methods that read bytes and belong to `SnappyInputStream` Types
37
53
*/
38
- class ReadInputStreamCall extends MethodCall {
54
+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
39
55
ReadInputStreamCall ( ) {
40
56
this .getReceiverType ( ) instanceof TypeInputStream and
41
57
this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
@@ -127,7 +143,7 @@ module ApacheCommons {
127
143
/**
128
144
* The methods that read bytes and belong to `*CompressorInputStream` Types
129
145
*/
130
- class ReadInputStreamCall extends MethodCall {
146
+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
131
147
ReadInputStreamCall ( ) {
132
148
this .getReceiverType ( ) instanceof TypeCompressors and
133
149
this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
@@ -172,7 +188,7 @@ module ApacheCommons {
172
188
/**
173
189
* The methods that read bytes and belong to `*ArchiveInputStream` Types
174
190
*/
175
- class ReadInputStreamCall extends MethodCall {
191
+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
176
192
ReadInputStreamCall ( ) {
177
193
this .getReceiverType ( ) instanceof TypeArchivers and
178
194
this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
@@ -240,7 +256,7 @@ module ApacheCommons {
240
256
/**
241
257
* The methods that read bytes and belong to `CompressorInputStream` or `ArchiveInputStream` Types
242
258
*/
243
- class ReadInputStreamCall extends MethodCall {
259
+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
244
260
ReadInputStreamCall ( ) {
245
261
(
246
262
this .getReceiverType ( ) instanceof TypeArchiveInputStream
@@ -282,7 +298,7 @@ module Zip4j {
282
298
/**
283
299
* The methods that read bytes and belong to `CompressorInputStream` or `ArchiveInputStream` Types
284
300
*/
285
- class ReadInputStreamCall extends MethodCall {
301
+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
286
302
ReadInputStreamCall ( ) {
287
303
this .getReceiverType ( ) instanceof TypeZipInputStream and
288
304
this .getMethod ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
@@ -307,7 +323,7 @@ module Zip {
307
323
/**
308
324
* The Types that are responsible for `ZipInputStream`, `GZIPInputStream`, `InflaterInputStream` Classes
309
325
*/
310
- class TypeInputStream extends RefType {
326
+ class TypeInputStream extends DecompressionBomb :: BombTypeInputStream {
311
327
TypeInputStream ( ) {
312
328
this .getASupertype * ( )
313
329
.hasQualifiedName ( "java.util.zip" ,
@@ -318,7 +334,7 @@ module Zip {
318
334
/**
319
335
* The methods that read bytes and belong to `*InputStream` Types
320
336
*/
321
- class ReadInputStreamCall extends MethodCall {
337
+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
322
338
ReadInputStreamCall ( ) {
323
339
this .getReceiverType ( ) instanceof TypeInputStream and
324
340
this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
0 commit comments