Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comparing file paths on manifest files to dedupe #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__author__ = 'socket.dev'
__version__ = '1.0.38'
__version__ = '1.0.39'
25 changes: 18 additions & 7 deletions socketsecurity/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("\\", "/")
Expand All @@ -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)
Expand Down
Loading