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";
@@ -310,7 +311,7 @@ const assertV8RuntimeParameters = (
if (
(location.kind === "file" &&
!parameters.allowed_file_roots.some((root) =>
isWithinRoot(root, location.file_path),
isPathWithinRoot(root, location.file_path),
)) ||
(location.kind === "url" &&
!parameters.allowed_origins.includes(location.origin)) ||
@@ -321,13 +322,6 @@ const assertV8RuntimeParameters = (
);
};
const isWithinRoot = (root: string, path: string): boolean => {
const remainder = relative(root, path);
return (
remainder === "" || (!remainder.startsWith("..") && !isAbsolute(remainder))
);
};
const normalizeV8Inspection = (
result: JavaScriptRuntimeObservation,
): NormalizedV8Inspection => ({