From 619d1a62f6aad6a116902a5a7435d9c01b9b9f71 Mon Sep 17 00:00:00 2001 From: Eric Hibbs Date: Tue, 14 Jan 2025 13:50:52 -0800 Subject: [PATCH] comparing file paths on manifest files to dedupe --- socketsecurity/__init__.py | 2 +- socketsecurity/core/__init__.py | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index 2cb21d0..a4e85c5 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,2 +1,2 @@ __author__ = 'socket.dev' -__version__ = '1.0.38' +__version__ = '1.0.39' diff --git a/socketsecurity/core/__init__.py b/socketsecurity/core/__init__.py index 0291a40..47a1467 100644 --- a/socketsecurity/core/__init__.py +++ b/socketsecurity/core/__init__.py @@ -475,6 +475,10 @@ def create_full_scan(files: list, params: FullScanParams, workspace: str) -> Ful send_files = [] create_full_start = time.time() log.debug("Creating new full scan") + + # Track unique paths (case-insensitive) to avoid duplicates + seen_paths = {} + for file in files: if platform.system() == "Windows": file = file.replace("\\", "/") @@ -484,20 +488,27 @@ def create_full_scan(files: list, params: FullScanParams, workspace: str) -> Ful path = "." name = file full_path = f"{path}/{name}" + if full_path.startswith(workspace): key = full_path[len(workspace):] else: key = full_path key = key.lstrip("/") key = key.lstrip("./") - payload = ( - key, - ( - name, - open(full_path, 'rb') + + # Use lowercase version of key for deduplication + lower_key = key.lower() + if lower_key not in seen_paths: + seen_paths[lower_key] = key + payload = ( + key, + ( + name, + open(full_path, 'rb') + ) ) - ) - send_files.append(payload) + send_files.append(payload) + query_params = urlencode(params.__dict__) full_uri = f"{full_scan_path}?{query_params}" response = do_request(full_uri, method="POST", files=send_files)