Files
my-pi/pi-permission-system/src/safe-system-paths.ts
T

19 lines
591 B
TypeScript

/**
* Paths that are universally safe and should never trigger external-directory checks.
* These are OS device files: read returns EOF or process streams, write discards or goes to process streams.
*/
export const SAFE_SYSTEM_PATHS: ReadonlySet<string> = new Set([
"/dev/null",
"/dev/stdin",
"/dev/stdout",
"/dev/stderr",
]);
/**
* Returns true if the given normalized path is a safe OS device file
* that should never trigger external-directory checks.
*/
export function isSafeSystemPath(normalizedPath: string): boolean {
return SAFE_SYSTEM_PATHS.has(normalizedPath);
}