fix(daemon): normalize audit paths
This commit is contained in:
@@ -12,10 +12,15 @@ const VERSION_MANAGER_MARKERS = [
|
||||
"/nvs/",
|
||||
];
|
||||
|
||||
function getPathModule(platform: NodeJS.Platform) {
|
||||
return platform === "win32" ? path.win32 : path.posix;
|
||||
}
|
||||
|
||||
function normalizeForCompare(input: string, platform: NodeJS.Platform): string {
|
||||
const normalized = path.normalize(input);
|
||||
const pathModule = getPathModule(platform);
|
||||
const normalized = pathModule.normalize(input).replaceAll("\\", "/");
|
||||
if (platform === "win32") {
|
||||
return normalized.replaceAll("\\", "/").toLowerCase();
|
||||
return normalized.toLowerCase();
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
@@ -31,12 +36,13 @@ function buildSystemNodeCandidates(
|
||||
return ["/usr/local/bin/node", "/usr/bin/node"];
|
||||
}
|
||||
if (platform === "win32") {
|
||||
const pathModule = getPathModule(platform);
|
||||
const programFiles = env.ProgramFiles ?? "C:\\Program Files";
|
||||
const programFilesX86 =
|
||||
env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
||||
return [
|
||||
path.join(programFiles, "nodejs", "node.exe"),
|
||||
path.join(programFilesX86, "nodejs", "node.exe"),
|
||||
pathModule.join(programFiles, "nodejs", "node.exe"),
|
||||
pathModule.join(programFilesX86, "nodejs", "node.exe"),
|
||||
];
|
||||
}
|
||||
return [];
|
||||
|
||||
@@ -194,10 +194,15 @@ function isBunRuntime(execPath: string): boolean {
|
||||
return base === "bun" || base === "bun.exe";
|
||||
}
|
||||
|
||||
function getPathModule(platform: NodeJS.Platform) {
|
||||
return platform === "win32" ? path.win32 : path.posix;
|
||||
}
|
||||
|
||||
function normalizePathEntry(entry: string, platform: NodeJS.Platform): string {
|
||||
const normalized = path.normalize(entry);
|
||||
const pathModule = getPathModule(platform);
|
||||
const normalized = pathModule.normalize(entry).replaceAll("\\", "/");
|
||||
if (platform === "win32") {
|
||||
return normalized.replaceAll("\\", "/").toLowerCase();
|
||||
return normalized.toLowerCase();
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
@@ -221,7 +226,7 @@ function auditGatewayServicePath(
|
||||
|
||||
const expected = getMinimalServicePathParts({ platform });
|
||||
const parts = servicePath
|
||||
.split(path.delimiter)
|
||||
.split(getPathModule(platform).delimiter)
|
||||
.map((entry) => entry.trim())
|
||||
.filter(Boolean);
|
||||
const normalizedParts = parts.map((entry) =>
|
||||
|
||||
Reference in New Issue
Block a user