@socketsecurity/cli-with-sentry 1.1.93 → 1.1.95

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cli.js +247 -24
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +4 -4
  5. package/dist/constants.js.map +1 -1
  6. package/dist/socket-completion.bash +2 -2
  7. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  8. package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
  9. package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +1 -1
  10. package/dist/types/commands/manifest/convert_sbt_to_maven.d.mts.map +1 -1
  11. package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
  12. package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +1 -1
  13. package/dist/types/commands/scan/exclude-paths.d.mts +47 -0
  14. package/dist/types/commands/scan/exclude-paths.d.mts.map +1 -0
  15. package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
  16. package/dist/types/commands/scan/handle-scan-reach.d.mts.map +1 -1
  17. package/dist/types/commands/scan/output-scan-reach.d.mts.map +1 -1
  18. package/dist/types/commands/scan/perform-reachability-analysis.d.mts +1 -0
  19. package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
  20. package/dist/types/commands/scan/reachability-flags.d.mts +1 -0
  21. package/dist/types/commands/scan/reachability-flags.d.mts.map +1 -1
  22. package/dist/types/utils/glob.d.mts +14 -0
  23. package/dist/types/utils/glob.d.mts.map +1 -1
  24. package/dist/types/utils/path-resolve.d.mts +5 -0
  25. package/dist/types/utils/path-resolve.d.mts.map +1 -1
  26. package/dist/utils.js +273 -244
  27. package/dist/utils.js.map +1 -1
  28. package/dist/vendor.js +8181 -8181
  29. package/package.json +3 -3
package/dist/utils.js CHANGED
@@ -4320,6 +4320,256 @@ function parseGitRemoteUrl(remoteUrl) {
4320
4320
  } : result;
4321
4321
  }
4322
4322
 
4323
+ const DEFAULT_IGNORE_FOR_GIT_IGNORE = globs.defaultIgnore.filter(p => !p.endsWith('.gitignore'));
4324
+ const IGNORED_DIRS = [
4325
+ // Taken from ignore-by-default:
4326
+ // https://github.com/novemberborn/ignore-by-default/blob/v2.1.0/index.js
4327
+ '.git',
4328
+ // Git repository files, see <https://git-scm.com/>
4329
+ '.log',
4330
+ // Log files emitted by tools such as `tsserver`, see <https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29>
4331
+ '.nyc_output',
4332
+ // Temporary directory where nyc stores coverage data, see <https://github.com/bcoe/nyc>
4333
+ '.sass-cache',
4334
+ // Cache folder for node-sass, see <https://github.com/sass/node-sass>
4335
+ '.yarn',
4336
+ // Where node modules are installed when using Yarn, see <https://yarnpkg.com/>
4337
+ 'bower_components',
4338
+ // Where Bower packages are installed, see <http://bower.io/>
4339
+ 'coverage',
4340
+ // Standard output directory for code coverage reports, see <https://github.com/gotwarlost/istanbul>
4341
+ constants.NODE_MODULES,
4342
+ // Where Node modules are installed, see <https://nodejs.org/>
4343
+ // Taken from globby:
4344
+ // https://github.com/sindresorhus/globby/blob/v14.0.2/ignore.js#L11-L16
4345
+ 'flow-typed'];
4346
+ const IGNORED_DIR_PATTERNS = IGNORED_DIRS.map(i => `**/${i}`);
4347
+ async function getWorkspaceGlobs(agent, cwd = process.cwd()) {
4348
+ let workspacePatterns;
4349
+ if (agent === constants.PNPM) {
4350
+ const workspacePath = path.join(cwd, 'pnpm-workspace.yaml');
4351
+ const yml = await fs$1.safeReadFile(workspacePath);
4352
+ if (yml) {
4353
+ try {
4354
+ workspacePatterns = vendor.distExports$1.parse(yml)?.packages;
4355
+ } catch {}
4356
+ }
4357
+ } else {
4358
+ workspacePatterns = (await packages.readPackageJson(cwd, {
4359
+ throws: false
4360
+ }))?.['workspaces'];
4361
+ }
4362
+ return Array.isArray(workspacePatterns) ? workspacePatterns.filter(strings.isNonEmptyString).map(workspacePatternToGlobPattern) : [];
4363
+ }
4364
+ function ignoreFileLinesToGlobPatterns(lines, filepath, cwd) {
4365
+ const base = path.relative(cwd, path.dirname(filepath)).replace(/\\/g, '/');
4366
+ const patterns = [];
4367
+ for (let i = 0, {
4368
+ length
4369
+ } = lines; i < length; i += 1) {
4370
+ const pattern = lines[i].trim();
4371
+ if (pattern.length > 0 && pattern.charCodeAt(0) !== 35 /*'#'*/) {
4372
+ patterns.push(ignorePatternToMinimatch(pattern.length && pattern.charCodeAt(0) === 33 /*'!'*/ ? `!${path.posix.join(base, pattern.slice(1))}` : path.posix.join(base, pattern)));
4373
+ }
4374
+ }
4375
+ return patterns;
4376
+ }
4377
+ function ignoreFileToGlobPatterns(content, filepath, cwd) {
4378
+ return ignoreFileLinesToGlobPatterns(content.split(/\r?\n/), filepath, cwd);
4379
+ }
4380
+
4381
+ // Based on `@eslint/compat` convertIgnorePatternToMinimatch.
4382
+ // Apache v2.0 licensed
4383
+ // Copyright Nicholas C. Zakas
4384
+ // https://github.com/eslint/rewrite/blob/compat-v1.2.1/packages/compat/src/ignore-file.js#L28
4385
+ function ignorePatternToMinimatch(pattern) {
4386
+ const isNegated = pattern.startsWith('!');
4387
+ const negatedPrefix = isNegated ? '!' : '';
4388
+ const patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd();
4389
+ // Special cases.
4390
+ if (patternToTest === '' || patternToTest === '**' || patternToTest === '/**' || patternToTest === '**') {
4391
+ return `${negatedPrefix}${patternToTest}`;
4392
+ }
4393
+ const firstIndexOfSlash = patternToTest.indexOf('/');
4394
+ const matchEverywherePrefix = firstIndexOfSlash === -1 || firstIndexOfSlash === patternToTest.length - 1 ? '**/' : '';
4395
+ const patternWithoutLeadingSlash = firstIndexOfSlash === 0 ? patternToTest.slice(1) : patternToTest;
4396
+ // Escape `{` and `(` because in gitignore patterns they are just
4397
+ // literal characters without any specific syntactic meaning,
4398
+ // while in minimatch patterns they can form brace expansion or extglob syntax.
4399
+ //
4400
+ // For example, gitignore pattern `src/{a,b}.js` ignores file `src/{a,b}.js`.
4401
+ // But, the same minimatch pattern `src/{a,b}.js` ignores files `src/a.js` and `src/b.js`.
4402
+ // Minimatch pattern `src/\{a,b}.js` is equivalent to gitignore pattern `src/{a,b}.js`.
4403
+ const escapedPatternWithoutLeadingSlash = patternWithoutLeadingSlash.replaceAll(/(?=((?:\\.|[^{(])*))\1([{(])/guy, '$1\\$2');
4404
+ const matchInsideSuffix = patternToTest.endsWith('/**') ? '/*' : '';
4405
+ return `${negatedPrefix}${matchEverywherePrefix}${escapedPatternWithoutLeadingSlash}${matchInsideSuffix}`;
4406
+ }
4407
+
4408
+ // fast-glob silently discards `ignore` entries that end in `/` (it
4409
+ // treats them as literal directory paths, not glob patterns). The
4410
+ // gitignore convention of writing directory entries as `dist/` lands
4411
+ // here as `**/dist/` after `ignorePatternToMinimatch`, which fast-glob
4412
+ // then drops — defeating the entire ignore. Strip the trailing slash
4413
+ // so fast-glob actually honors the pattern.
4414
+ function stripTrailingSlash(pattern) {
4415
+ if (pattern.length > 1 && pattern.charCodeAt(pattern.length - 1) === 47 /*'/'*/) {
4416
+ return pattern.slice(0, -1);
4417
+ }
4418
+ return pattern;
4419
+ }
4420
+ function workspacePatternToGlobPattern(workspace) {
4421
+ const {
4422
+ length
4423
+ } = workspace;
4424
+ if (!length) {
4425
+ return '';
4426
+ }
4427
+ // If the workspace ends with "/"
4428
+ if (workspace.charCodeAt(length - 1) === 47 /*'/'*/) {
4429
+ return `${workspace}/*/package.json`;
4430
+ }
4431
+ // If the workspace ends with "/**"
4432
+ if (workspace.charCodeAt(length - 1) === 42 /*'*'*/ && workspace.charCodeAt(length - 2) === 42 /*'*'*/ && workspace.charCodeAt(length - 3) === 47 /*'/'*/) {
4433
+ return `${workspace}/*/**/package.json`;
4434
+ }
4435
+ // Things like "packages/a" or "packages/*"
4436
+ return `${workspace}/package.json`;
4437
+ }
4438
+ function createSupportedFilesFilter(supportedFiles) {
4439
+ const patterns = getSupportedFilePatterns(supportedFiles);
4440
+ return filepath => vendor.micromatchExports.some(filepath, patterns, {
4441
+ dot: true,
4442
+ nocase: true
4443
+ });
4444
+ }
4445
+ function getSupportedFilePatterns(supportedFiles) {
4446
+ const patterns = [];
4447
+ for (const key of Object.keys(supportedFiles)) {
4448
+ const supported = supportedFiles[key];
4449
+ if (supported) {
4450
+ patterns.push(...Object.values(supported).map(p => `**/${p.pattern}`));
4451
+ }
4452
+ }
4453
+ return patterns;
4454
+ }
4455
+ async function globWithGitIgnore(patterns, options) {
4456
+ const {
4457
+ additionalIgnores,
4458
+ cwd = process.cwd(),
4459
+ filter,
4460
+ socketConfig,
4461
+ ...additionalOptions
4462
+ } = {
4463
+ __proto__: null,
4464
+ ...options
4465
+ };
4466
+ const ignores = new Set(IGNORED_DIR_PATTERNS);
4467
+ const projectIgnorePaths = socketConfig?.projectIgnorePaths;
4468
+ if (Array.isArray(projectIgnorePaths)) {
4469
+ const ignorePatterns = ignoreFileLinesToGlobPatterns(projectIgnorePaths, path.join(cwd, '.gitignore'), cwd);
4470
+ for (const pattern of ignorePatterns) {
4471
+ ignores.add(pattern);
4472
+ }
4473
+ }
4474
+ const gitIgnoreStream = vendor.outExports.globStream(['**/.gitignore'], {
4475
+ absolute: true,
4476
+ cwd,
4477
+ dot: true,
4478
+ ignore: DEFAULT_IGNORE_FOR_GIT_IGNORE
4479
+ });
4480
+ for await (const ignorePatterns of streams.transform(gitIgnoreStream, async filepath => ignoreFileToGlobPatterns((await fs$1.safeReadFile(filepath)) ?? '', filepath, cwd), {
4481
+ concurrency: 8
4482
+ })) {
4483
+ for (const p of ignorePatterns) {
4484
+ ignores.add(p);
4485
+ }
4486
+ }
4487
+ let hasNegatedPattern = false;
4488
+ for (const p of ignores) {
4489
+ if (p.charCodeAt(0) === 33 /*'!'*/) {
4490
+ hasNegatedPattern = true;
4491
+ break;
4492
+ }
4493
+ }
4494
+
4495
+ // CLI-supplied `additionalIgnores` are already anchored minimatch — they
4496
+ // must not pass through the `ignore` package (whose gitignore "match
4497
+ // anywhere" semantics would re-interpret a bare `tests` to match
4498
+ // `subdir/tests/foo.json`). Keep them in fast-glob's ignore list across
4499
+ // both paths; only gitignore-translated entries go into the `ig` matcher.
4500
+ const cliMinimatchIgnores = additionalIgnores ?? [];
4501
+ const globOptions = {
4502
+ __proto__: null,
4503
+ absolute: true,
4504
+ cwd,
4505
+ dot: true,
4506
+ ignore: hasNegatedPattern ? [...globs.defaultIgnore, ...cliMinimatchIgnores] : [...ignores, ...cliMinimatchIgnores].map(stripTrailingSlash),
4507
+ ...additionalOptions
4508
+ };
4509
+
4510
+ // When no filter is provided and no negated patterns exist, use the fast path.
4511
+ if (!hasNegatedPattern && !filter) {
4512
+ return await vendor.outExports.glob(patterns, globOptions);
4513
+ }
4514
+ // Add support for negated "ignore" patterns which many globbing libraries,
4515
+ // including 'fast-glob', 'globby', and 'tinyglobby', lack support for.
4516
+ // Use streaming to avoid unbounded memory accumulation.
4517
+ // This is critical for large monorepos with 100k+ files.
4518
+ const results = [];
4519
+ const ig = hasNegatedPattern ? vendor.ignoreExports().add([...ignores]) : null;
4520
+ const stream = vendor.outExports.globStream(patterns, globOptions);
4521
+ for await (const p of stream) {
4522
+ // Check gitignore patterns with negation support.
4523
+ if (ig) {
4524
+ // Note: the input files must be INSIDE the cwd. If you get strange looking
4525
+ // relative path errors here, most likely your path is outside the given cwd.
4526
+ const relPath = globOptions.absolute ? path.relative(cwd, p) : p;
4527
+ if (ig.ignores(relPath)) {
4528
+ continue;
4529
+ }
4530
+ }
4531
+ // Apply the optional filter to reduce memory usage.
4532
+ // When scanning large monorepos, this filters early (e.g., to manifest files only)
4533
+ // instead of accumulating all 100k+ files and filtering later.
4534
+ if (filter && !filter(p)) {
4535
+ continue;
4536
+ }
4537
+ results.push(p);
4538
+ }
4539
+ return results;
4540
+ }
4541
+ async function globWorkspace(agent, cwd = process.cwd()) {
4542
+ const workspaceGlobs = await getWorkspaceGlobs(agent, cwd);
4543
+ return workspaceGlobs.length ? await vendor.outExports.glob(workspaceGlobs, {
4544
+ absolute: true,
4545
+ cwd,
4546
+ dot: true,
4547
+ ignore: globs.defaultIgnore
4548
+ }) : [];
4549
+ }
4550
+ function isReportSupportedFile(filepath, supportedFiles) {
4551
+ const patterns = getSupportedFilePatterns(supportedFiles);
4552
+ return vendor.micromatchExports.some(filepath, patterns, {
4553
+ dot: true,
4554
+ nocase: true
4555
+ });
4556
+ }
4557
+ function pathsToGlobPatterns(paths, cwd) {
4558
+ // TODO: Does not support `~/` paths.
4559
+ return paths.map(p => {
4560
+ // Convert current directory references to glob patterns.
4561
+ if (p === '.' || p === './') {
4562
+ return '**/*';
4563
+ }
4564
+ const absolutePath = path.isAbsolute(p) ? p : path.resolve(cwd ?? process.cwd(), p);
4565
+ // If the path is a directory, scan it recursively for all files.
4566
+ if (fs$1.isDirSync(absolutePath)) {
4567
+ return `${p}/**/*`;
4568
+ }
4569
+ return p;
4570
+ });
4571
+ }
4572
+
4323
4573
  /**
4324
4574
  * Package URL (PURL) utilities for Socket CLI.
4325
4575
  * Implements the PURL specification for universal package identification.
@@ -4585,248 +4835,6 @@ async function findUp(name, options) {
4585
4835
  return undefined;
4586
4836
  }
4587
4837
 
4588
- const DEFAULT_IGNORE_FOR_GIT_IGNORE = globs.defaultIgnore.filter(p => !p.endsWith('.gitignore'));
4589
- const IGNORED_DIRS = [
4590
- // Taken from ignore-by-default:
4591
- // https://github.com/novemberborn/ignore-by-default/blob/v2.1.0/index.js
4592
- '.git',
4593
- // Git repository files, see <https://git-scm.com/>
4594
- '.log',
4595
- // Log files emitted by tools such as `tsserver`, see <https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29>
4596
- '.nyc_output',
4597
- // Temporary directory where nyc stores coverage data, see <https://github.com/bcoe/nyc>
4598
- '.sass-cache',
4599
- // Cache folder for node-sass, see <https://github.com/sass/node-sass>
4600
- '.yarn',
4601
- // Where node modules are installed when using Yarn, see <https://yarnpkg.com/>
4602
- 'bower_components',
4603
- // Where Bower packages are installed, see <http://bower.io/>
4604
- 'coverage',
4605
- // Standard output directory for code coverage reports, see <https://github.com/gotwarlost/istanbul>
4606
- constants.NODE_MODULES,
4607
- // Where Node modules are installed, see <https://nodejs.org/>
4608
- // Taken from globby:
4609
- // https://github.com/sindresorhus/globby/blob/v14.0.2/ignore.js#L11-L16
4610
- 'flow-typed'];
4611
- const IGNORED_DIR_PATTERNS = IGNORED_DIRS.map(i => `**/${i}`);
4612
- async function getWorkspaceGlobs(agent, cwd = process.cwd()) {
4613
- let workspacePatterns;
4614
- if (agent === constants.PNPM) {
4615
- const workspacePath = path.join(cwd, 'pnpm-workspace.yaml');
4616
- const yml = await fs$1.safeReadFile(workspacePath);
4617
- if (yml) {
4618
- try {
4619
- workspacePatterns = vendor.distExports$1.parse(yml)?.packages;
4620
- } catch {}
4621
- }
4622
- } else {
4623
- workspacePatterns = (await packages.readPackageJson(cwd, {
4624
- throws: false
4625
- }))?.['workspaces'];
4626
- }
4627
- return Array.isArray(workspacePatterns) ? workspacePatterns.filter(strings.isNonEmptyString).map(workspacePatternToGlobPattern) : [];
4628
- }
4629
- function ignoreFileLinesToGlobPatterns(lines, filepath, cwd) {
4630
- const base = path.relative(cwd, path.dirname(filepath)).replace(/\\/g, '/');
4631
- const patterns = [];
4632
- for (let i = 0, {
4633
- length
4634
- } = lines; i < length; i += 1) {
4635
- const pattern = lines[i].trim();
4636
- if (pattern.length > 0 && pattern.charCodeAt(0) !== 35 /*'#'*/) {
4637
- patterns.push(ignorePatternToMinimatch(pattern.length && pattern.charCodeAt(0) === 33 /*'!'*/ ? `!${path.posix.join(base, pattern.slice(1))}` : path.posix.join(base, pattern)));
4638
- }
4639
- }
4640
- return patterns;
4641
- }
4642
- function ignoreFileToGlobPatterns(content, filepath, cwd) {
4643
- return ignoreFileLinesToGlobPatterns(content.split(/\r?\n/), filepath, cwd);
4644
- }
4645
-
4646
- // Based on `@eslint/compat` convertIgnorePatternToMinimatch.
4647
- // Apache v2.0 licensed
4648
- // Copyright Nicholas C. Zakas
4649
- // https://github.com/eslint/rewrite/blob/compat-v1.2.1/packages/compat/src/ignore-file.js#L28
4650
- function ignorePatternToMinimatch(pattern) {
4651
- const isNegated = pattern.startsWith('!');
4652
- const negatedPrefix = isNegated ? '!' : '';
4653
- const patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd();
4654
- // Special cases.
4655
- if (patternToTest === '' || patternToTest === '**' || patternToTest === '/**' || patternToTest === '**') {
4656
- return `${negatedPrefix}${patternToTest}`;
4657
- }
4658
- const firstIndexOfSlash = patternToTest.indexOf('/');
4659
- const matchEverywherePrefix = firstIndexOfSlash === -1 || firstIndexOfSlash === patternToTest.length - 1 ? '**/' : '';
4660
- const patternWithoutLeadingSlash = firstIndexOfSlash === 0 ? patternToTest.slice(1) : patternToTest;
4661
- // Escape `{` and `(` because in gitignore patterns they are just
4662
- // literal characters without any specific syntactic meaning,
4663
- // while in minimatch patterns they can form brace expansion or extglob syntax.
4664
- //
4665
- // For example, gitignore pattern `src/{a,b}.js` ignores file `src/{a,b}.js`.
4666
- // But, the same minimatch pattern `src/{a,b}.js` ignores files `src/a.js` and `src/b.js`.
4667
- // Minimatch pattern `src/\{a,b}.js` is equivalent to gitignore pattern `src/{a,b}.js`.
4668
- const escapedPatternWithoutLeadingSlash = patternWithoutLeadingSlash.replaceAll(/(?=((?:\\.|[^{(])*))\1([{(])/guy, '$1\\$2');
4669
- const matchInsideSuffix = patternToTest.endsWith('/**') ? '/*' : '';
4670
- return `${negatedPrefix}${matchEverywherePrefix}${escapedPatternWithoutLeadingSlash}${matchInsideSuffix}`;
4671
- }
4672
-
4673
- // fast-glob silently discards `ignore` entries that end in `/` (it
4674
- // treats them as literal directory paths, not glob patterns). The
4675
- // gitignore convention of writing directory entries as `dist/` lands
4676
- // here as `**/dist/` after `ignorePatternToMinimatch`, which fast-glob
4677
- // then drops — defeating the entire ignore. Strip the trailing slash
4678
- // so fast-glob actually honors the pattern.
4679
- function stripTrailingSlash(pattern) {
4680
- if (pattern.length > 1 && pattern.charCodeAt(pattern.length - 1) === 47 /*'/'*/) {
4681
- return pattern.slice(0, -1);
4682
- }
4683
- return pattern;
4684
- }
4685
- function workspacePatternToGlobPattern(workspace) {
4686
- const {
4687
- length
4688
- } = workspace;
4689
- if (!length) {
4690
- return '';
4691
- }
4692
- // If the workspace ends with "/"
4693
- if (workspace.charCodeAt(length - 1) === 47 /*'/'*/) {
4694
- return `${workspace}/*/package.json`;
4695
- }
4696
- // If the workspace ends with "/**"
4697
- if (workspace.charCodeAt(length - 1) === 42 /*'*'*/ && workspace.charCodeAt(length - 2) === 42 /*'*'*/ && workspace.charCodeAt(length - 3) === 47 /*'/'*/) {
4698
- return `${workspace}/*/**/package.json`;
4699
- }
4700
- // Things like "packages/a" or "packages/*"
4701
- return `${workspace}/package.json`;
4702
- }
4703
- function createSupportedFilesFilter(supportedFiles) {
4704
- const patterns = getSupportedFilePatterns(supportedFiles);
4705
- return filepath => vendor.micromatchExports.some(filepath, patterns, {
4706
- dot: true,
4707
- nocase: true
4708
- });
4709
- }
4710
- function getSupportedFilePatterns(supportedFiles) {
4711
- const patterns = [];
4712
- for (const key of Object.keys(supportedFiles)) {
4713
- const supported = supportedFiles[key];
4714
- if (supported) {
4715
- patterns.push(...Object.values(supported).map(p => `**/${p.pattern}`));
4716
- }
4717
- }
4718
- return patterns;
4719
- }
4720
- async function globWithGitIgnore(patterns, options) {
4721
- const {
4722
- cwd = process.cwd(),
4723
- filter,
4724
- socketConfig,
4725
- ...additionalOptions
4726
- } = {
4727
- __proto__: null,
4728
- ...options
4729
- };
4730
- const ignores = new Set(IGNORED_DIR_PATTERNS);
4731
- const projectIgnorePaths = socketConfig?.projectIgnorePaths;
4732
- if (Array.isArray(projectIgnorePaths)) {
4733
- const ignorePatterns = ignoreFileLinesToGlobPatterns(projectIgnorePaths, path.join(cwd, '.gitignore'), cwd);
4734
- for (const pattern of ignorePatterns) {
4735
- ignores.add(pattern);
4736
- }
4737
- }
4738
- const gitIgnoreStream = vendor.outExports.globStream(['**/.gitignore'], {
4739
- absolute: true,
4740
- cwd,
4741
- dot: true,
4742
- ignore: DEFAULT_IGNORE_FOR_GIT_IGNORE
4743
- });
4744
- for await (const ignorePatterns of streams.transform(gitIgnoreStream, async filepath => ignoreFileToGlobPatterns((await fs$1.safeReadFile(filepath)) ?? '', filepath, cwd), {
4745
- concurrency: 8
4746
- })) {
4747
- for (const p of ignorePatterns) {
4748
- ignores.add(p);
4749
- }
4750
- }
4751
- let hasNegatedPattern = false;
4752
- for (const p of ignores) {
4753
- if (p.charCodeAt(0) === 33 /*'!'*/) {
4754
- hasNegatedPattern = true;
4755
- break;
4756
- }
4757
- }
4758
- const globOptions = {
4759
- __proto__: null,
4760
- absolute: true,
4761
- cwd,
4762
- dot: true,
4763
- ignore: hasNegatedPattern ? globs.defaultIgnore : [...ignores].map(stripTrailingSlash),
4764
- ...additionalOptions
4765
- };
4766
-
4767
- // When no filter is provided and no negated patterns exist, use the fast path.
4768
- if (!hasNegatedPattern && !filter) {
4769
- return await vendor.outExports.glob(patterns, globOptions);
4770
- }
4771
- // Add support for negated "ignore" patterns which many globbing libraries,
4772
- // including 'fast-glob', 'globby', and 'tinyglobby', lack support for.
4773
- // Use streaming to avoid unbounded memory accumulation.
4774
- // This is critical for large monorepos with 100k+ files.
4775
- const results = [];
4776
- const ig = hasNegatedPattern ? vendor.ignoreExports().add([...ignores]) : null;
4777
- const stream = vendor.outExports.globStream(patterns, globOptions);
4778
- for await (const p of stream) {
4779
- // Check gitignore patterns with negation support.
4780
- if (ig) {
4781
- // Note: the input files must be INSIDE the cwd. If you get strange looking
4782
- // relative path errors here, most likely your path is outside the given cwd.
4783
- const relPath = globOptions.absolute ? path.relative(cwd, p) : p;
4784
- if (ig.ignores(relPath)) {
4785
- continue;
4786
- }
4787
- }
4788
- // Apply the optional filter to reduce memory usage.
4789
- // When scanning large monorepos, this filters early (e.g., to manifest files only)
4790
- // instead of accumulating all 100k+ files and filtering later.
4791
- if (filter && !filter(p)) {
4792
- continue;
4793
- }
4794
- results.push(p);
4795
- }
4796
- return results;
4797
- }
4798
- async function globWorkspace(agent, cwd = process.cwd()) {
4799
- const workspaceGlobs = await getWorkspaceGlobs(agent, cwd);
4800
- return workspaceGlobs.length ? await vendor.outExports.glob(workspaceGlobs, {
4801
- absolute: true,
4802
- cwd,
4803
- dot: true,
4804
- ignore: globs.defaultIgnore
4805
- }) : [];
4806
- }
4807
- function isReportSupportedFile(filepath, supportedFiles) {
4808
- const patterns = getSupportedFilePatterns(supportedFiles);
4809
- return vendor.micromatchExports.some(filepath, patterns, {
4810
- dot: true,
4811
- nocase: true
4812
- });
4813
- }
4814
- function pathsToGlobPatterns(paths, cwd) {
4815
- // TODO: Does not support `~/` paths.
4816
- return paths.map(p => {
4817
- // Convert current directory references to glob patterns.
4818
- if (p === '.' || p === './') {
4819
- return '**/*';
4820
- }
4821
- const absolutePath = path.isAbsolute(p) ? p : path.resolve(cwd ?? process.cwd(), p);
4822
- // If the path is a directory, scan it recursively for all files.
4823
- if (fs$1.isDirSync(absolutePath)) {
4824
- return `${p}/**/*`;
4825
- }
4826
- return p;
4827
- });
4828
- }
4829
-
4830
4838
  function findBinPathDetailsSync(binName) {
4831
4839
  const rawBinPaths = bin.whichBinSync(binName, {
4832
4840
  all: true,
@@ -4905,8 +4913,26 @@ function findNpmDirPathSync(npmBinPath) {
4905
4913
  thePath = parent;
4906
4914
  }
4907
4915
  }
4916
+ /**
4917
+ * Converts absolute scan targets inside cwd back to cwd-relative paths before
4918
+ * glob expansion. SCA excludes passed through `additionalIgnores` are anchored
4919
+ * to cwd, so package discovery needs target globs in the same coordinate
4920
+ * system for fast-glob to apply those ignores consistently.
4921
+ */
4922
+ function normalizeScanInputPath(pathToNormalize, cwd) {
4923
+ if (!path.isAbsolute(pathToNormalize)) {
4924
+ return pathToNormalize;
4925
+ }
4926
+ const relativePath = path.relative(cwd, pathToNormalize);
4927
+ const isInsideCwd = relativePath === '' || !relativePath.startsWith('..') && !path.isAbsolute(relativePath);
4928
+ if (!isInsideCwd) {
4929
+ return pathToNormalize;
4930
+ }
4931
+ return stripTrailingSlash(relativePath.replaceAll('\\', '/')) || '.';
4932
+ }
4908
4933
  async function getPackageFilesForScan(inputPaths, supportedFiles, options) {
4909
4934
  const {
4935
+ additionalIgnores,
4910
4936
  config: socketConfig,
4911
4937
  cwd = process.cwd()
4912
4938
  } = {
@@ -4918,7 +4944,9 @@ async function getPackageFilesForScan(inputPaths, supportedFiles, options) {
4918
4944
  // all files in memory. This is critical for large monorepos with 100k+ files
4919
4945
  // where accumulating all paths before filtering causes OOM errors.
4920
4946
  const filter = createSupportedFilesFilter(supportedFiles);
4921
- return await globWithGitIgnore(pathsToGlobPatterns(inputPaths, options?.cwd), {
4947
+ const normalizedInputPaths = inputPaths.map(p => normalizeScanInputPath(p, cwd));
4948
+ return await globWithGitIgnore(pathsToGlobPatterns(normalizedInputPaths, cwd), {
4949
+ additionalIgnores,
4922
4950
  cwd,
4923
4951
  filter,
4924
4952
  socketConfig
@@ -7905,6 +7933,7 @@ exports.socketPackageLink = socketPackageLink;
7905
7933
  exports.spawnCdxgenDlx = spawnCdxgenDlx;
7906
7934
  exports.spawnCoanaDlx = spawnCoanaDlx;
7907
7935
  exports.spawnSynpDlx = spawnSynpDlx;
7936
+ exports.stripTrailingSlash = stripTrailingSlash;
7908
7937
  exports.suggestOrgSlug = suggestOrgSlug;
7909
7938
  exports.tildify = tildify;
7910
7939
  exports.toFilterConfig = toFilterConfig;
@@ -7917,5 +7946,5 @@ exports.updateConfigValue = updateConfigValue;
7917
7946
  exports.walkNestedMap = walkNestedMap;
7918
7947
  exports.webLink = webLink;
7919
7948
  exports.writeSocketJson = writeSocketJson;
7920
- //# debugId=1376ca2b-1ca3-4d1d-8c29-09378ce0da4a
7949
+ //# debugId=2070e850-060e-4077-8aaa-c4564f5f74e5
7921
7950
  //# sourceMappingURL=utils.js.map