Skip to content

Commit e007d2e

Browse files
jfblaaclaude
andcommitted
fix(manifest): harden scan-root --exclude-paths anchoring
- Treat a module on another Windows drive than the scan root as outside it instead of letting Path.relativize throw, in every JVM exclusion helper. - Normalize `\` separators in the glob compiler, so single-root runs match Windows-style patterns too and callers pass --exclude-paths straight through. - Smoke-check that a module outside the scan root is never excluded, clear stale records between checks and keep build output visible. - Document the narrowed and re-anchored behaviour in the changelog and the --exclude-paths help. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 04d20d1 commit e007d2e

24 files changed

Lines changed: 82 additions & 51 deletions

‎CHANGELOG.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

77
## [Unreleased]
88

9+
### Changed
10+
- Modules outside the scan root can no longer be excluded with `--exclude-paths`; `**/x` used to match a `../x` module by accident. Single-root runs whose Maven or Gradle options relocate the build root (`-f`, `-p`) now match patterns relative to the current directory, as documented.
11+
912
### Fixed
10-
- `--exclude-paths` now also excludes modules a build reaches outside its own directory, such as Maven `../` modules and relocated Gradle projects, when Socket facts are generated for each build root.
13+
- `--exclude-paths` patterns are now matched relative to the scan root in every build root. They now also exclude modules a build reaches outside its own directory (Maven `../` modules, relocated Gradle projects) and modules matched by wildcards that span a build-root boundary, such as `*/core`.
14+
- `--exclude-paths` patterns written with Windows `\` separators now exclude JVM build modules in single-root runs too.
1115

1216
## [1.12.2](https://github.com/SocketDev/socket-cli/releases/tag/v1.12.2) - 2026-10-30
1317

‎src/commands/manifest/cmd-manifest-auto.test.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('socket manifest auto', async () => {
2323
$ socket manifest auto [options] [CWD=.]
2424
2525
Options
26-
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project.
26+
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module outside CWD cannot be excluded.
2727
--verbose Enable debug output (only for auto itself; sub-steps need to have it pre-configured), may help when running into errors
2828
2929
Tries to figure out what language your target repo uses. If it finds a

‎src/commands/manifest/cmd-manifest-dynamic-sbom-inference.test.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('socket manifest dynamic-sbom-inference', async () => {
3333
CWD itself.
3434
3535
Options
36-
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project.
36+
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module outside CWD cannot be excluded.
3737
--ignore-unresolved Warn on unresolved dependencies instead of failing the run (unresolved deps are not emitted to the facts files); overrides each build's socket.json setting
3838
--json Output as JSON
3939
--markdown Output as Markdown

‎src/commands/manifest/cmd-manifest-gradle.test.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('socket manifest gradle', async () => {
2525
Options
2626
--bin Location of the gradle binary to use, default: ./gradlew if present, else gradle on PATH
2727
--exclude-configs When generating facts: comma-separated glob patterns; Gradle configurations matching any pattern are skipped (applied after --include-configs)
28-
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project.
28+
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module outside CWD cannot be excluded.
2929
--facts Emit a Socket facts JSON file (\`gradle.socket.facts.json\`) describing the resolved dependency graph. This is the default; pass \`--pom\` to generate \`pom.xml\` files instead
3030
--gradle-opts Additional options to pass on to ./gradlew, see \`./gradlew --help\`
3131
--ignore-unresolved When generating facts: warn on unresolved dependencies instead of failing the run (unresolved deps are not emitted to the facts file)

‎src/commands/manifest/cmd-manifest-kotlin.test.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('socket manifest kotlin', async () => {
2525
Options
2626
--bin Location of the gradle binary to use, default: ./gradlew if present, else gradle on PATH
2727
--exclude-configs When generating facts: comma-separated glob patterns; Gradle configurations matching any pattern are skipped (applied after --include-configs)
28-
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project.
28+
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module outside CWD cannot be excluded.
2929
--facts Emit a Socket facts JSON file (\`gradle.socket.facts.json\`) describing the resolved dependency graph. This is the default; pass \`--pom\` to generate \`pom.xml\` files instead
3030
--gradle-opts Additional options to pass on to ./gradlew, see \`./gradlew --help\`
3131
--ignore-unresolved When generating facts: warn on unresolved dependencies instead of failing the run (unresolved deps are not emitted to the facts file)

‎src/commands/manifest/cmd-manifest-maven.test.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('socket manifest maven', async () => {
2424
Options
2525
--bin Location of the maven binary to use, default: ./mvnw if present, else mvn on PATH
2626
--exclude-configs Comma-separated glob patterns; Maven scopes matching any pattern are skipped (applied after --include-configs)
27-
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project.
27+
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module outside CWD cannot be excluded.
2828
--ignore-unresolved Warn on unresolved dependencies instead of failing the run (unresolved deps are not emitted to the facts file)
2929
--include-configs Comma-separated glob patterns matched against Maven dependency scopes (case-sensitive; \`*\`, \`?\`, and \`[...]\` wildcards). Only scopes matching at least one pattern are resolved. e.g. \`compile,runtime\`. Default: every scope
3030
--maven-opts Additional options to pass on to maven, e.g. \`-P <profile> -s <settings.xml>\`

‎src/commands/manifest/cmd-manifest-scala.test.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('socket manifest scala', async () => {
2525
Options
2626
--bin Location of sbt binary to use
2727
--exclude-configs When generating facts: comma-separated glob patterns; sbt configurations matching any pattern are skipped (applied after --include-configs)
28-
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project.
28+
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module outside CWD cannot be excluded.
2929
--facts Emit a Socket facts JSON file (\`sbt.socket.facts.json\`) describing the resolved dependency graph. This is the default; pass \`--pom\` to generate \`pom.xml\` files instead
3030
--ignore-unresolved When generating facts: warn on unresolved dependencies instead of failing the run (unresolved deps are not emitted to the facts file)
3131
--include-configs When generating facts: comma-separated glob patterns matched against sbt configuration names (case-sensitive; \`*\`, \`?\`, and \`[...]\` wildcards). Only configurations matching at least one pattern are resolved. e.g. \`compile,test\`. Default: compile,optional,provided,runtime,test

‎src/commands/manifest/generate-recursive-manifests.mts‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
readOrDefaultSocketJson,
2525
readSocketJsonCascade,
2626
} from '../../utils/socket-json.mts'
27-
import { projectIgnorePathsToReachExcludePaths } from '../scan/exclude-paths.mts'
2827

2928
import type { BuildRoot } from './discover-manifest-roots.mts'
3029
import type { BuildTool } from './scripts/build-tool.mts'
@@ -169,12 +168,6 @@ async function runEcosystemCandidates({
169168
}): Promise<RecursiveManifestOutcome[]> {
170169
const outcomes: RecursiveManifestOutcome[] = []
171170
const covered = new Set<string>()
172-
// Relative to the scan root: a build can reach modules outside its own
173-
// directory (Maven `../x` modules, relocated Gradle projects).
174-
const scanExcludePaths = projectIgnorePathsToReachExcludePaths(excludePaths, {
175-
cwd: realCwd,
176-
target: realCwd,
177-
})
178171
for (const [ecosystem, roots] of candidatesByTool) {
179172
const disabledRoots: DisabledRoot[] = []
180173
const configByDir = new Map<string, EcosystemBuildConfig>()
@@ -230,8 +223,10 @@ async function runEcosystemCandidates({
230223
ecosystem,
231224
entryFile,
232225
excludeConfigs,
226+
// Relative to the scan root: a build can reach modules outside its
227+
// own directory (Maven `../x` modules, relocated Gradle projects).
233228
excludeBase: realCwd,
234-
excludePaths: scanExcludePaths,
229+
excludePaths,
235230
hints: {
236231
continueOnInstallErrorsFlag: withFiles
237232
? REACH_CONTINUE_ON_INSTALL_ERRORS_FLAG

‎src/commands/manifest/manifest-flags.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export const excludePathsFlag: MeowFlags = {
88
type: 'string',
99
isMultiple: true,
1010
description:
11-
'List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (`--cwd` if set): `tests` matches only `<cwd>/tests`; use `**/tests` to match at any depth. Negation patterns (`!path`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project.',
11+
'List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (`--cwd` if set): `tests` matches only `<cwd>/tests`; use `**/tests` to match at any depth. Negation patterns (`!path`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module outside CWD cannot be excluded.',
1212
},
1313
}

‎src/commands/manifest/scripts/exclude-paths-glob.mts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,13 @@ export function excludePathGlobToRegexSource(glob: string): string {
129129
}
130130
}
131131

132+
// A Windows-style `foo\bar` means the path `foo/bar`.
132133
export function compileExcludePathPatterns(
133134
paths: readonly string[] | undefined,
134135
): string[] {
135-
return (paths ?? []).map(excludePathGlobToRegexSource)
136+
return (paths ?? []).map(p =>
137+
excludePathGlobToRegexSource(p.replaceAll('\\', '/')),
138+
)
136139
}
137140

138141
// Transport form handed to the build-tool scripts: comma-joined pattern

0 commit comments

Comments
 (0)