22import logging
33from typing import List , Optional , Any , Tuple , Union
44
5- from credsweeper .common .constants import RECURSIVE_SCAN_LIMITATION
5+ from credsweeper .common .constants import RECURSIVE_SCAN_LIMITATION , MIN_DATA_LEN
66from credsweeper .config import Config
77from credsweeper .credentials import Candidate
88from credsweeper .credentials .augment_candidates import augment_candidates
2323from .html_scanner import HtmlScanner
2424from .jks_scanner import JksScanner
2525from .lang_scanner import LangScanner
26+ from .lzma_scanner import LzmaScanner
2627from .mxfile_scanner import MxfileScanner
2728from .pdf_scanner import PdfScanner
2829from .pkcs12_scanner import Pkcs12Scanner
@@ -48,6 +49,7 @@ class DeepScanner(
4849 HtmlScanner , #
4950 JksScanner , #
5051 LangScanner , #
52+ LzmaScanner , #
5153 PdfScanner , #
5254 Pkcs12Scanner , #
5355 PptxScanner , #
@@ -106,6 +108,9 @@ def get_deep_scanners(data: bytes, file_type: str, depth: int) -> Tuple[List[Any
106108 elif Util .is_bzip2 (data ):
107109 if 0 < depth :
108110 deep_scanners .append (Bzip2Scanner )
111+ elif Util .is_lzma (data ):
112+ if 0 < depth :
113+ deep_scanners .append (LzmaScanner )
109114 elif Util .is_tar (data ):
110115 if 0 < depth :
111116 deep_scanners .append (TarScanner )
@@ -239,15 +244,18 @@ def recursive_scan(
239244 recursive_limit_size: maximal bytes of opened files to prevent recursive zip-bomb attack
240245 """
241246 candidates : List [Candidate ] = []
242- logger .debug ("Start data_scan: size=%d, depth=%d, limit=%d, path=%s, info=%s" , len (data_provider .data ), depth ,
243- recursive_limit_size , data_provider .file_path , data_provider .info )
244-
245247 if 0 > depth :
246248 # break recursion if maximal depth is reached
247- logger .debug ("bottom reached %s recursive_limit_size:%d" , data_provider .file_path , recursive_limit_size )
249+ logger .debug ("Bottom reached %s recursive_limit_size:%d" , data_provider .file_path , recursive_limit_size )
248250 return candidates
249-
250251 depth -= 1
252+ if MIN_DATA_LEN > len (data_provider .data ):
253+ # break recursion if maximal depth is reached
254+ logger .debug ("Too small data: size=%d, depth=%d, limit=%d, path=%s, info=%s" , len (data_provider .data ),
255+ depth , recursive_limit_size , data_provider .file_path , data_provider .info )
256+ return candidates
257+ logger .debug ("Start data_scan: size=%d, depth=%d, limit=%d, path=%s, info=%s" , len (data_provider .data ), depth ,
258+ recursive_limit_size , data_provider .file_path , data_provider .info )
251259
252260 if FilePathExtractor .is_find_by_ext_file (self .config , data_provider .file_type ):
253261 # Skip scanning file and makes fake candidate due the extension is suspicious
0 commit comments