fix(paths): enforce selected path contracts at admission (#9465)

This commit is contained in:
morluto authored and GitHub committed 2026-11-09 03:14:48 +08:00
1 parent b4b881116f
commit 25d3c7237f
18 files changed
+57 -93

No files matched your search

+12 -5
View File
@@ -1,6 +1,9 @@
import { z } from "zod";
import { digestSchema } from "../digests.js";
import { localPathStringSchema } from "../localPath.js";
import {
absoluteLocalPathStringSchema,
localPathStringSchema,
} from "../localPath.js";
export const PYTHON_PYC_HEADER_BYTES = 16;
export const PYTHON_PYC_HASH_BASED = 0x1;
@@ -70,10 +73,7 @@ export const PYTHON_PYC_LIMIT_MAXIMA = {
max_string_bytes: 8 * 1024 * 1024,
} as const;
export const inspectPythonPycInputSchema = z.strictObject({
path: localPathStringSchema.describe(
"Absolute filesystem path to the selected CPython .pyc file",
),
export const pythonPycLimitsSchema = z.strictObject({
max_file_bytes: z
.number()
.int()
@@ -112,6 +112,13 @@ export const inspectPythonPycInputSchema = z.strictObject({
),
});
export type PythonPycLimits = z.infer<typeof pythonPycLimitsSchema>;
export const inspectPythonPycInputSchema = pythonPycLimitsSchema.extend({
path: absoluteLocalPathStringSchema.describe(
"Absolute filesystem path to the selected CPython .pyc file",
),
});
export const PYTHON_PYC_CONST_PREVIEW_LIMIT = 80;
/** Integers up to 256 bits fit the 80-character preview in decimal. */
export const PYTHON_PYC_INT_PREVIEW_BITS = 256;