fix: consolidate boundary ownership and cleanup failure paths (#477)

This commit is contained in:
morluto
2026-09-08 10:59:13 +08:00
committed by GitHub
parent c490d85045
commit 2160d4fae5
138 changed files with 2220 additions and 1781 deletions
@@ -1,6 +1,7 @@
import { createHash } from "node:crypto";
import { isAbsolute, relative } from "node:path";
import { isAbsolute } from "node:path";
import { isPathWithinRoot } from "./localPath.js";
import canonicalize from "canonicalize";
import { z } from "zod";
@@ -33,7 +34,7 @@ export const parseActiveElectronCapture = (
.parse(evidence.parameters);
if (
result.application.application_path !== parameters.application_path ||
!isWithinRoot(
!isPathWithinRoot(
parameters.application_root,
result.application.application_path,
)
@@ -129,10 +130,3 @@ const digestCanonical = (value: unknown): string => {
throw new TypeError("Runtime reconciliation could not canonicalize input");
return createHash("sha256").update(encoded).digest("hex");
};
const isWithinRoot = (root: string, path: string): boolean => {
const remainder = relative(root, path);
return (
remainder === "" || (!remainder.startsWith("..") && !isAbsolute(remainder))
);
};