@socketsecurity/cli-with-sentry 1.1.55 → 1.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,13 @@ import type { SocketYml } from '@socketsecurity/config';
3
3
  import type { SocketSdkSuccessResult } from '@socketsecurity/sdk';
4
4
  import type { Options as GlobOptions } from 'fast-glob';
5
5
  export declare function filterBySupportedScanFiles(filepaths: string[] | readonly string[], supportedFiles: SocketSdkSuccessResult<'getReportSupportedFiles'>['data']): string[];
6
+ export declare function createSupportedFilesFilter(supportedFiles: SocketSdkSuccessResult<'getReportSupportedFiles'>['data']): (filepath: string) => boolean;
6
7
  export declare function getSupportedFilePatterns(supportedFiles: SocketSdkSuccessResult<'getReportSupportedFiles'>['data']): string[];
7
8
  type GlobWithGitIgnoreOptions = GlobOptions & {
9
+ // Optional filter function to apply during streaming.
10
+ // When provided, only files passing this filter are accumulated.
11
+ // This is critical for memory efficiency when scanning large monorepos.
12
+ filter?: ((filepath: string) => boolean) | undefined;
8
13
  socketConfig?: SocketYml | undefined;
9
14
  };
10
15
  export declare function globWithGitIgnore(patterns: string[] | readonly string[], options: GlobWithGitIgnoreOptions): Promise<string[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"glob.d.mts","sourceRoot":"","sources":["../../../src/utils/glob.mts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AA4IvD,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EACvC,cAAc,EAAE,sBAAsB,CAAC,yBAAyB,CAAC,CAAC,MAAM,CAAC,GACx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AsB,CAAC,yBAAyB,CAAC,CAAC,MAAM,CAAC,EACzE,OAAO,CAAC,EAAE,0BAA0B,GAAG,SAAS,GAC/C,OAAO,CAAC,MAAM,EAAE,CAAC,CAmBnB"}
package/dist/utils.js CHANGED
@@ -4458,11 +4458,11 @@ function workspacePatternToGlobPattern(workspace) {
4458
4458
  // Things like "packages/a" or "packages/*"
4459
4459
  return `${workspace}/package.json`;
4460
4460
  }
4461
- function filterBySupportedScanFiles(filepaths, supportedFiles) {
4461
+ function createSupportedFilesFilter(supportedFiles) {
4462
4462
  const patterns = getSupportedFilePatterns(supportedFiles);
4463
- return filepaths.filter(p => vendor.micromatchExports.some(p, patterns, {
4463
+ return filepath => vendor.micromatchExports.some(filepath, patterns, {
4464
4464
  dot: true
4465
- }));
4465
+ });
4466
4466
  }
4467
4467
  function getSupportedFilePatterns(supportedFiles) {
4468
4468
  const patterns = [];
@@ -4477,6 +4477,7 @@ function getSupportedFilePatterns(supportedFiles) {
4477
4477
  async function globWithGitIgnore(patterns, options) {
4478
4478
  const {
4479
4479
  cwd = process.cwd(),
4480
+ filter,
4480
4481
  socketConfig,
4481
4482
  ...additionalOptions
4482
4483
  } = {
@@ -4519,24 +4520,37 @@ async function globWithGitIgnore(patterns, options) {
4519
4520
  ignore: hasNegatedPattern ? globs.defaultIgnore : [...ignores],
4520
4521
  ...additionalOptions
4521
4522
  };
4522
- if (!hasNegatedPattern) {
4523
+
4524
+ // When no filter is provided and no negated patterns exist, use the fast path.
4525
+ if (!hasNegatedPattern && !filter) {
4523
4526
  return await vendor.outExports.glob(patterns, globOptions);
4524
4527
  }
4525
-
4526
4528
  // Add support for negated "ignore" patterns which many globbing libraries,
4527
4529
  // including 'fast-glob', 'globby', and 'tinyglobby', lack support for.
4528
- const filtered = [];
4529
- const ig = vendor.ignoreExports().add([...ignores]);
4530
+ // Use streaming to avoid unbounded memory accumulation.
4531
+ // This is critical for large monorepos with 100k+ files.
4532
+ const results = [];
4533
+ const ig = hasNegatedPattern ? vendor.ignoreExports().add([...ignores]) : null;
4530
4534
  const stream = vendor.outExports.globStream(patterns, globOptions);
4531
4535
  for await (const p of stream) {
4532
- // Note: the input files must be INSIDE the cwd. If you get strange looking
4533
- // relative path errors here, most likely your path is outside the given cwd.
4534
- const relPath = globOptions.absolute ? path.relative(cwd, p) : p;
4535
- if (!ig.ignores(relPath)) {
4536
- filtered.push(p);
4536
+ // Check gitignore patterns with negation support.
4537
+ if (ig) {
4538
+ // Note: the input files must be INSIDE the cwd. If you get strange looking
4539
+ // relative path errors here, most likely your path is outside the given cwd.
4540
+ const relPath = globOptions.absolute ? path.relative(cwd, p) : p;
4541
+ if (ig.ignores(relPath)) {
4542
+ continue;
4543
+ }
4544
+ }
4545
+ // Apply the optional filter to reduce memory usage.
4546
+ // When scanning large monorepos, this filters early (e.g., to manifest files only)
4547
+ // instead of accumulating all 100k+ files and filtering later.
4548
+ if (filter && !filter(p)) {
4549
+ continue;
4537
4550
  }
4551
+ results.push(p);
4538
4552
  }
4539
- return filtered;
4553
+ return results;
4540
4554
  }
4541
4555
  async function globWorkspace(agent, cwd = process.cwd()) {
4542
4556
  const workspaceGlobs = await getWorkspaceGlobs(agent, cwd);
@@ -4655,11 +4669,16 @@ async function getPackageFilesForScan(inputPaths, supportedFiles, options) {
4655
4669
  __proto__: null,
4656
4670
  ...options
4657
4671
  };
4658
- const filepaths = await globWithGitIgnore(pathsToGlobPatterns(inputPaths, options?.cwd), {
4672
+
4673
+ // Apply the supported files filter during streaming to avoid accumulating
4674
+ // all files in memory. This is critical for large monorepos with 100k+ files
4675
+ // where accumulating all paths before filtering causes OOM errors.
4676
+ const filter = createSupportedFilesFilter(supportedFiles);
4677
+ return await globWithGitIgnore(pathsToGlobPatterns(inputPaths, options?.cwd), {
4659
4678
  cwd,
4679
+ filter,
4660
4680
  socketConfig
4661
4681
  });
4662
- return filterBySupportedScanFiles(filepaths, supportedFiles);
4663
4682
  }
4664
4683
 
4665
4684
  function exitWithBinPathError$2(binName) {
@@ -7571,5 +7590,5 @@ exports.updateConfigValue = updateConfigValue;
7571
7590
  exports.walkNestedMap = walkNestedMap;
7572
7591
  exports.webLink = webLink;
7573
7592
  exports.writeSocketJson = writeSocketJson;
7574
- //# debugId=68d86e29-e96e-422d-9344-803beda1a6e1
7593
+ //# debugId=daad3417-21c0-4204-b2a0-c6f5984819a4
7575
7594
  //# sourceMappingURL=utils.js.map