Skip to content

Commit

Permalink
enchancement
Browse files Browse the repository at this point in the history
  • Loading branch information
babenek committed Jul 17, 2024
1 parent 722757e commit 0402379
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions credsweeper/deep_scanner/bzip2_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions credsweeper/deep_scanner/gzip_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0402379

Please sign in to comment.