Skip to content

Conversation

@alexandru-manea-snyk
Copy link

@alexandru-manea-snyk alexandru-manea-snyk commented Dec 4, 2025

https://snyksec.atlassian.net/browse/PS-87

Summary

This PR optimizes the fileupload.Client to support effective batching when receiving pre-filtered lists of files (from the Secrets CLI extension). This ensures uploads respect the scm-bundle-store limits.

Problem

The core issue lay in the file batching logic, which failed to group files effectively when provided with a list of pre-filtered files (rather than a directory walk), resulting in batches containing only a single file. This rapid sequence of small uploads quickly exhausted the partCountPerRevision limit (50) in scm-bundle-store service.

Furthermore, the per-file root calculation caused relative file locations to be flattened, resulting in the loss of the original directory hierarchy once uploaded.

Solution

We now aggregate the input files into a channel and dynamically calculate a Common Root (lowest common ancestor) for the group. This allows the fileupload.Client to effectively group multiple files into a single batch while respecting the addPathsToRevision signature, which enforces a single root argument per batch.

Behavior Change (before vs. after)

The logic change affects how the relative path is determined. Previously, using a per-file root effectively flattened the path (ignoring directory structure). Now, the directory structure is preserved relative to the calculated common root.

Example File: /Users/user/snyk-code/fake-leaks-small/data/static/web3-snippets/JuiceShopSBT.sol

Before:

  • Test ran from: .../fake-leaks-small/
  • Uploaded as: JuiceShopSBT.sol (Flattened - effectively Base(file))

After:

  • Test ran from: .../fake-leaks-small/

  • Uploaded as: data/static/web3-snippets/JuiceShopSBT.sol (Tree Preserved relative to common root)

  • Test ran from: .../fake-leaks-small/data

  • Uploaded as: static/web3-snippets/JuiceShopSBT.sol (Tree Preserved relative to data)

@snyk-io
Copy link

snyk-io bot commented Dec 4, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-io
Copy link

snyk-io bot commented Dec 4, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@alexandru-manea-snyk alexandru-manea-snyk changed the title feat: Improve file upload client for secrets cli extension usecases [PS-86] fix: Fix part count limit exceeded by enabling multi-file batching for filtered file lists [PS-86] Dec 5, 2025
@alexandru-manea-snyk alexandru-manea-snyk marked this pull request as ready for review December 8, 2025 11:15
@alexandru-manea-snyk alexandru-manea-snyk requested review from a team as code owners December 8, 2025 11:15
@alina-d-m alina-d-m changed the title fix: Fix part count limit exceeded by enabling multi-file batching for filtered file lists [PS-86] fix: fix part count limit exceeded by enabling multi-file batching [PS-87] Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants