Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/orange-teeth-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nodesecure/scanner": minor
---

Implement a new maxConcurrency options to configure how much NPM tarballs we scan/limit in depWalker
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ interface Options {
*
* @default Infinity
*/
maxDepth?: number;
readonly maxDepth?: number;

/**
* Maximum concurrency to fetch and scan NPM tarballs
* @default 8
*/
readonly maxConcurrency?: number;

/**
* Includes development dependencies in the walk.
Expand Down
5 changes: 3 additions & 2 deletions workspaces/scanner/src/depWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ export async function depWalker(
location,
vulnerabilityStrategy = Vulnera.strategies.NONE,
registry,
npmRcConfig
npmRcConfig,
maxConcurrency = 8
} = options;

const statsCollector = new StatsCollector({ logger }, { isVerbose });
Expand Down Expand Up @@ -205,7 +206,7 @@ export async function depWalker(
const fetchedMetadataPackages = new Set<string>();
const operationsQueue: Promise<void>[] = [];

const locker = new Mutex({ concurrency: 5 });
const locker = new Mutex({ concurrency: maxConcurrency });
locker.on(
MutexRelease,
() => logger.tick(ScannerLoggerEvents.analysis.tarball)
Expand Down
6 changes: 6 additions & 0 deletions workspaces/scanner/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ export interface Options {
*/
readonly maxDepth?: number;

/**
* Maximum concurrency to fetch and scan NPM tarballs
* @default 8
*/
readonly maxConcurrency?: number;

readonly registry?: string | URL;

/**
Expand Down
Loading