Skip to content

Commit cb4aea9

Browse files
committed
docs(scan): clarify exclude path handling
1 parent a2e3799 commit cb4aea9

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/commands/scan/exclude-paths.mts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ function toPosixPath(path: string): string {
5757
}
5858

5959
/**
60-
* Fans --exclude-paths out to both exclusion sinks: the SCA manifest-discovery
61-
* pipeline (via fast-glob's `ignore` option, as already-anchored minimatch
62-
* patterns) and the reachability analyzer (via `reachExcludePaths`, ultimately
63-
* coana's --exclude-dirs).
60+
* Derives the two scan-time forms of --exclude-paths: anchored minimatch
61+
* patterns for SCA manifest discovery, and target-relative paths for Coana's
62+
* reachability analysis.
6463
*/
6564
export function applyFullExcludePaths({
6665
cwd,
@@ -105,9 +104,9 @@ const DEGENERATE_EXCLUDE_PATHS = new Set<string>([
105104
/**
106105
* Validates --exclude-paths entries before they reach either exclusion sink.
107106
* Rejects gitignore-style negations (coana's --exclude-dirs has no negation
108-
* form), absolute paths (`/repo/tests` silently no-ops on both sinks today),
109-
* patterns escaping the scan root via `..`, and degenerate match-everything
110-
* sentinels like `.`, `**`, `/`.
107+
* form), absolute paths (the flag is scan-root relative), patterns escaping
108+
* the scan root via `..`, and degenerate match-everything sentinels like `.`,
109+
* `**`, `/`.
111110
*/
112111
export function assertValidExcludePaths(paths: readonly string[]): void {
113112
for (const p of paths) {
@@ -156,7 +155,7 @@ export function excludePathToScanIgnores(input: string): string[] {
156155
}
157156

158157
/**
159-
* Re-anchors Socket-scan-root patterns onto the reachability analysis target.
158+
* Re-anchors --exclude-paths patterns onto the reachability analysis target.
160159
* Coana matches --exclude-dirs relative to whichever directory it was invoked
161160
* on, so when the analysis target is a nested subdirectory, scan-root
162161
* patterns need their target prefix stripped. Patterns that fall outside the

src/utils/path-resolve.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ export type PackageFilesForScanOptions = {
110110
config?: SocketYml | undefined
111111
}
112112

113+
/**
114+
* Converts absolute scan targets inside cwd back to cwd-relative paths before
115+
* glob expansion. SCA excludes passed through `additionalIgnores` are anchored
116+
* to cwd, so package discovery needs target globs in the same coordinate
117+
* system for fast-glob to apply those ignores consistently.
118+
*/
113119
function normalizeScanInputPath(pathToNormalize: string, cwd: string): string {
114120
if (!path.isAbsolute(pathToNormalize)) {
115121
return pathToNormalize

0 commit comments

Comments
 (0)