@@ -81,16 +81,11 @@ module XerialSnappy {
8181 this .getReceiverType ( ) instanceof TypeInputStream and
8282 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
8383 }
84-
85- /**
86- * A method Access as a sink which responsible for reading bytes
87- */
88- MethodCall getAByteRead ( ) { result = this }
8984 }
9085
9186 class Sink extends DecompressionBomb:: Sink {
9287 override predicate sink ( DataFlow:: Node sink , DecompressionBomb:: DecompressionState state ) {
93- sink .asExpr ( ) = any ( ReadInputStreamCall r ) . getAByteRead ( ) and
88+ sink .asExpr ( ) = any ( ReadInputStreamCall r ) and
9489 state instanceof DecompressionBomb:: XerialSnappy
9590 }
9691 }
@@ -203,16 +198,11 @@ module ApacheCommons {
203198 this .getReceiverType ( ) instanceof TypeCompressors and
204199 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
205200 }
206-
207- /**
208- * A method Access as a sink which responsible for reading bytes
209- */
210- MethodCall getAByteRead ( ) { result = this }
211201 }
212202
213203 class Sink extends DecompressionBomb:: Sink {
214204 override predicate sink ( DataFlow:: Node sink , DecompressionBomb:: DecompressionState state ) {
215- sink .asExpr ( ) = any ( ReadInputStreamCall r ) . getAByteRead ( ) and
205+ sink .asExpr ( ) = any ( ReadInputStreamCall r ) and
216206 state instanceof DecompressionBomb:: ApacheCommons
217207 }
218208 }
@@ -278,16 +268,11 @@ module ApacheCommons {
278268 this .getReceiverType ( ) instanceof TypeArchivers and
279269 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
280270 }
281-
282- /**
283- * A method Access as a sink which responsible for reading bytes
284- */
285- MethodCall getAByteRead ( ) { result = this }
286271 }
287272
288273 class Sink extends DecompressionBomb:: Sink {
289274 override predicate sink ( DataFlow:: Node sink , DecompressionBomb:: DecompressionState state ) {
290- sink .asExpr ( ) = any ( ReadInputStreamCall r ) . getAByteRead ( ) and
275+ sink .asExpr ( ) = any ( ReadInputStreamCall r ) and
291276 state instanceof DecompressionBomb:: ApacheCommons
292277 }
293278 }
@@ -367,16 +352,11 @@ module ApacheCommons {
367352 ) and
368353 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
369354 }
370-
371- /**
372- * A method Access as a sink which responsible for reading bytes
373- */
374- MethodCall getAByteRead ( ) { result = this }
375355 }
376356
377357 class Sink extends DecompressionBomb:: Sink {
378358 override predicate sink ( DataFlow:: Node sink , DecompressionBomb:: DecompressionState state ) {
379- sink .asExpr ( ) = any ( ReadInputStreamCall r ) . getAByteRead ( ) and
359+ sink .asExpr ( ) = any ( ReadInputStreamCall r ) and
380360 state instanceof DecompressionBomb:: ApacheCommons
381361 }
382362 }
@@ -404,16 +384,11 @@ module Zip4j {
404384 this .getReceiverType ( ) instanceof TypeZipInputStream and
405385 this .getMethod ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
406386 }
407-
408- /**
409- * A method Access as a sink which responsible for reading bytes
410- */
411- MethodCall getAByteRead ( ) { result = this }
412387 }
413388
414389 class Sink extends DecompressionBomb:: Sink {
415390 override predicate sink ( DataFlow:: Node sink , DecompressionBomb:: DecompressionState state ) {
416- sink .asExpr ( ) = any ( ReadInputStreamCall r ) . getAByteRead ( ) and
391+ sink .asExpr ( ) = any ( ReadInputStreamCall r ) and
417392 state instanceof DecompressionBomb:: Zip4j
418393 }
419394 }
@@ -446,40 +421,6 @@ module Zip4j {
446421 }
447422}
448423
449- /**
450- * Providing sinks that can be related to reading uncontrolled buffer and bytes for `org.apache.commons.io` package
451- */
452- module CommonsIO {
453- /**
454- * The Access to Methods which work with byes and inputStreams and buffers
455- */
456- class IOUtils extends MethodCall {
457- IOUtils ( ) {
458- this .getMethod ( )
459- .hasName ( [
460- "copy" , "copyLarge" , "read" , "readFully" , "readLines" , "toBufferedInputStream" ,
461- "toByteArray" , "toCharArray" , "toString" , "buffer"
462- ] ) and
463- this .getMethod ( ) .getDeclaringType ( ) .hasQualifiedName ( "org.apache.commons.io" , "IOUtils" )
464- }
465- }
466-
467- class Sink extends DecompressionBomb:: Sink {
468- override predicate sink ( DataFlow:: Node sink , DecompressionBomb:: DecompressionState state ) {
469- sink .asExpr ( ) = any ( IOUtils r ) .getArgument ( 0 ) and
470- (
471- state instanceof DecompressionBomb:: Zip4j
472- or
473- state instanceof DecompressionBomb:: Inflator
474- or
475- state instanceof DecompressionBomb:: ApacheCommons
476- or
477- state instanceof DecompressionBomb:: XerialSnappy
478- )
479- }
480- }
481- }
482-
483424/**
484425 * Providing Decompression sinks and additional taint steps for `java.util.zip` package
485426 */
@@ -503,16 +444,11 @@ module Zip {
503444 this .getReceiverType ( ) instanceof TypeInputStream and
504445 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
505446 }
506-
507- /**
508- * A method Access as a sink which responsible for reading bytes
509- */
510- MethodCall getAByteRead ( ) { result = this }
511447 }
512448
513449 class ReadInputStreamSink extends DecompressionBomb:: Sink {
514450 override predicate sink ( DataFlow:: Node sink , DecompressionBomb:: DecompressionState state ) {
515- sink .asExpr ( ) = any ( ReadInputStreamCall r ) . getAByteRead ( ) and
451+ sink .asExpr ( ) = any ( ReadInputStreamCall r ) and
516452 state instanceof DecompressionBomb:: UtilZip
517453 }
518454 }
@@ -602,16 +538,11 @@ module Zip {
602538 this .getReceiverType ( ) instanceof TypeInflator and
603539 this .getCallee ( ) .hasName ( "inflate" )
604540 }
605-
606- /**
607- * A method Access as a sink which responsible for reading bytes
608- */
609- MethodCall getAByteRead ( ) { result = this }
610541 }
611542
612543 class InflateSink extends DecompressionBomb:: Sink {
613544 override predicate sink ( DataFlow:: Node sink , DecompressionBomb:: DecompressionState state ) {
614- sink .asExpr ( ) = any ( InflateCall r ) . getAByteRead ( ) and
545+ sink .asExpr ( ) = any ( InflateCall r ) and
615546 state instanceof DecompressionBomb:: Inflator
616547 }
617548 }
0 commit comments