From 7720599b1b1547ca532fe198d53863e2c3251af4 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 17 Nov 2026 18:52:43 -0500 Subject: [PATCH] fix(scan): normalize Windows relative target paths --- src/utils/path-resolve.mts | 3 ++- src/utils/path-resolve.test.mts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/utils/path-resolve.mts b/src/utils/path-resolve.mts index 12dd96ad3f..268c0b6094 100644 --- a/src/utils/path-resolve.mts +++ b/src/utils/path-resolve.mts @@ -6,6 +6,7 @@ import { whichBinSync, } from '@socketsecurity/registry/lib/bin' import { isDirSync } from '@socketsecurity/registry/lib/fs' +import { normalizePath } from '@socketsecurity/registry/lib/path' import constants, { NODE_MODULES, NPM } from '../constants.mts' import { @@ -118,7 +119,7 @@ export type PackageFilesForScanOptions = { */ function normalizeScanInputPath(pathToNormalize: string, cwd: string): string { if (!path.isAbsolute(pathToNormalize)) { - return pathToNormalize + return stripTrailingSlash(normalizePath(pathToNormalize)) } const relativePath = path.relative(cwd, pathToNormalize) const isInsideCwd = diff --git a/src/utils/path-resolve.test.mts b/src/utils/path-resolve.test.mts index b416a44a1a..360b9e8021 100644 --- a/src/utils/path-resolve.test.mts +++ b/src/utils/path-resolve.test.mts @@ -138,6 +138,25 @@ describe('Path Resolve', () => { ]) }) + it('should normalize Windows-style relative directory paths', async () => { + const kernelDirPath = normalizePath(path.join(mockFixturePath, 'Kernel')) + mockTestFs({ + [`${kernelDirPath}/package.json`]: '{}', + [`${kernelDirPath}/nested/package.json`]: '{}', + }) + + const actual = await sortedGetPackageFilesFullScans( + ['.\\Kernel\\'], + globPatterns, + { cwd: mockFixturePath }, + ) + + expect(actual.map(normalizePath)).toEqual([ + `${kernelDirPath}/nested/package.json`, + `${kernelDirPath}/package.json`, + ]) + }) + it('should keep scan-root ignores effective when the input path is absolute', async () => { const appDirPath = normalizePath(path.join(mockFixturePath, 'apps/api')) mockTestFs({