Skip to content

Commit

Permalink
Merge pull request #53 from Xpertians/remove-tmp-folder-from-file-path
Browse files Browse the repository at this point in the history
Multiple changes to fix compatibility with Xmonkey-Server
  • Loading branch information
oscarvalenzuelab authored Jun 28, 2024
2 parents abc6524 + 18ea0a7 commit 132c5f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/xmonkey_curator/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.14'
__version__ = '0.1.15'
3 changes: 1 addition & 2 deletions src/xmonkey_curator/handlers/archive_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ def process(self, process_file_callback):
]
desc = f"Extracting {os.path.basename(self.file_path)}"
for file_path in tqdm(extracted_files, desc=desc[:75]):
process_file_callback(file_path)
process_file_callback(file_path, temp_dir)

def extract_archive(self, destination):
"""Extracts the archive to the specified destination directory."""
filetype = FileUtilities.identify_mime_type(self.file_path)
# print('mime:', filetype)
if zipfile.is_zipfile(self.file_path):
with zipfile.ZipFile(self.file_path, 'r') as zip_ref:
zip_ref.extractall(destination)
Expand Down
14 changes: 10 additions & 4 deletions src/xmonkey_curator/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def scan(path,
for file in files
]
for file_path in tqdm(all_files, desc="Scanning files"):
result = process_file(file_path, results, '',
result = process_file(file_path, '', results, '',
force_text, unpack,
export_symbols)
if result:
Expand All @@ -125,6 +125,7 @@ def scan(path,
logger.info(f"Scanning file: {path}")
result = process_file(
path,
'',
results,
'',
force_text,
Expand Down Expand Up @@ -162,6 +163,7 @@ def update_signatures_command():


def process_file(file_path,
temp_dir,
results,
archive_checksum=None,
force_text=False,
Expand Down Expand Up @@ -191,8 +193,9 @@ def process_file(file_path,
handler = ArchiveHandler(file_path)
archive_checksum = hash_md5
handler.process(
lambda path: process_file(
lambda path, temp_dir: process_file(
path,
temp_dir,
results,
archive_checksum,
force_text,
Expand Down Expand Up @@ -261,8 +264,9 @@ def process_file(file_path,
results.append(result)
archive_checksum = checksum
handler.process(
lambda path: process_file(
lambda path, temp_dir: process_file(
path,
temp_dir,
results,
archive_checksum,
force_text,
Expand All @@ -271,6 +275,8 @@ def process_file(file_path,
)
)
else:
if temp_dir:
file_path = file_path.replace(temp_dir+'/', '')
result = {
'file_path': file_path,
'mime_type': mime_type,
Expand Down Expand Up @@ -299,7 +305,7 @@ def process_file(file_path,
content = handler.extract_content()
lh = LicensesHandler()
LiD = lh.execute(file_name, content)
result['license'] = True
result['is_license'] = True
if LiD:
result['spdx_id'] = LiD
else:
Expand Down

0 comments on commit 132c5f4

Please sign in to comment.