Skip to content
1 min read · 195 words

Function: classifySandboxPathRejection()

ts
function classifySandboxPathRejection(
  input: string,
): SandboxPathRejection | undefined;

Defined in: src/batteries/sandbox/paths.ts:27

Classify an unambiguous host escape, or undefined when the path is acceptable.

Parameters

ParameterTypeDescription
inputstringThe model-supplied path, exactly as given.

Returns

| SandboxPathRejection | undefined

The rejection reason, or undefined to continue normalising.

Remarks

The REASON is returned, not just a boolean, because the narrated outcome carries it and the model acts on it: "paths are workspace-relative" is useless advice for a NUL byte, and a UNC form needs a different correction from a ~. Reporting every rejection as escape collapses five distinct mistakes into one unhelpful message.

ORDER IS LOAD-BEARING and matches the plan's step 1. Recognition runs on the CANONICAL separator representation (both / and \ treated as separators) but still BEFORE any stripping, so a slash-mixed form like /\server\share cannot slip past a naive prefix test and then become a root-relative path once separators are collapsed. UNC is distinguished from merely-repeated leading separators by having a NON-EMPTY first segment. Nothing is percent-decoded and nothing is case-folded: a literal %2e%2e is a filename, not traversal.