From 040237934d00ba756ecca7705b505ee71d145ec2 Mon Sep 17 00:00:00 2001 From: Roman Babenko Date: Wed, 17 Jul 2024 17:50:21 +0300 Subject: [PATCH] enchancement --- credsweeper/deep_scanner/bzip2_scanner.py | 6 ++++-- credsweeper/deep_scanner/gzip_scanner.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/credsweeper/deep_scanner/bzip2_scanner.py b/credsweeper/deep_scanner/bzip2_scanner.py index 4421a5f87..0d33b44b1 100644 --- a/credsweeper/deep_scanner/bzip2_scanner.py +++ b/credsweeper/deep_scanner/bzip2_scanner.py @@ -24,9 +24,11 @@ def data_scan( candidates = [] try: file_path = Path(data_provider.file_path) - new_path = file_path.as_posix()[:-4] if ".bz2" == file_path.suffix else file_path.as_posix() + new_path = file_path.as_posix() + if ".bz2" == file_path.suffix: + new_path = new_path[:-4] bzip2_content_provider = DataContentProvider(data=bz2.decompress(data_provider.data), - file_path=file_path.as_posix(), + file_path=new_path, file_type=Util.get_extension(new_path), info=f"{data_provider.info}|BZIP2|{new_path}") new_limit = recursive_limit_size - len(bzip2_content_provider.data) diff --git a/credsweeper/deep_scanner/gzip_scanner.py b/credsweeper/deep_scanner/gzip_scanner.py index d2c140538..1f8ec39ee 100644 --- a/credsweeper/deep_scanner/gzip_scanner.py +++ b/credsweeper/deep_scanner/gzip_scanner.py @@ -26,9 +26,11 @@ def data_scan( try: with gzip.open(io.BytesIO(data_provider.data)) as f: file_path = Path(data_provider.file_path) - new_path = file_path.as_posix()[:-3] if ".gz" == file_path.suffix else file_path.as_posix() + new_path = file_path.as_posix() + if ".gz" == file_path.suffix: + new_path = new_path[:-3] gzip_content_provider = DataContentProvider(data=f.read(), - file_path=file_path.as_posix(), + file_path=new_path, file_type=Util.get_extension(new_path), info=f"{data_provider.info}|GZIP|{new_path}") new_limit = recursive_limit_size - len(gzip_content_provider.data)