engine/request/path_confine

Path confinement helpers for static, SPA, and script resolution. Engine-internal — prevents URL / config path traversal outside app roots.
Description:
  • Path confinement helpers for static, SPA, and script resolution. Engine-internal — prevents URL / config path traversal outside app roots.

Methods

(inner) confineScriptPath(appBoxPath, relativeScript, optsopt) → {string|null}

Description:
  • Resolve a box script path under appBoxPath (routes.json or file routing).
Parameters:
Name Type Attributes Description
appBoxPath string
relativeScript string | Array.<string> e.g. "api/hello.js" or URL segments without extension
opts object <optional>
Properties
Name Type Attributes Default Description
appendJs boolean <optional>
false append ".js" after resolve (file-based routing)
Returns:
absolute script path inside box, or null
Type
string | null

(inner) hasUnsafePathSegments(segments) → {boolean}

Description:
  • True if any segment in the list is unsafe.
Parameters:
Name Type Description
segments Array.<string> | null | undefined
Returns:
Type
boolean

(inner) isInsideAppBox(candidatePath, appBoxPath, optionsopt) → {boolean}

Description:
  • True if candidate is inside the app box (must not be served as static WEB).
Parameters:
Name Type Attributes Description
candidatePath string
appBoxPath string
options object <optional>
Properties
Name Type Attributes Description
boundaryReal string <optional>
app.appBoxPathReal
Returns:
Type
boolean

(inner) isInsideAppWeb(candidatePath, appWebPath, optionsopt) → {boolean}

Description:
  • True if candidate is confined to app web root.
Parameters:
Name Type Attributes Description
candidatePath string
appWebPath string
options object <optional>
Properties
Name Type Attributes Description
boundaryReal string <optional>
app.appWebPathReal
Returns:
Type
boolean

(inner) isUnsafePathSegment(seg) → {boolean}

Description:
  • True if a single path segment is unsafe to join under a confinement root.
Parameters:
Name Type Description
seg string
Returns:
Type
boolean

(inner) relativeToSegments(relativePath) → {Array.<string>|null}

Description:
  • Split a relative path string into safe join segments, or null if unsafe. Rejects absolute paths and `..` components.
Parameters:
Name Type Description
relativePath string
Returns:
Type
Array.<string> | null

(inner) resolveConfinedPath(root, relativeOrSegments, optionsopt) → {string|null}

Description:
  • Resolve `relativeOrSegments` under `root` and require the result stay inside root. Returns absolute path, or null if the path escapes / is unsafe.
Parameters:
Name Type Attributes Description
root string confinement root (app web or box path)
relativeOrSegments string | Array.<string> | null | undefined relative path or URL segments
options object <optional>
Properties
Name Type Attributes Description
rootReal string <optional>
Precomputed realpath of root (app.appWebPathReal / appBoxPathReal)
Returns:
Type
string | null