MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / isPathSafe

Function isPathSafe

packages/node-runtime/src/data-dir-switch.ts:85–96  ·  view source on GitHub ↗
(targetPath: string)

Source from the content-addressed store, hash-verified

83}
84
85function isPathSafe(targetPath: string): boolean {
86 const normalizedTarget = targetPath.toLowerCase().replace(/\//g, '\\')
87
88 for (const dangerous of DANGEROUS_PATHS) {
89 const normalizedDangerous = dangerous.toLowerCase().replace(/\//g, '\\')
90 if (normalizedTarget.startsWith(normalizedDangerous)) {
91 return false
92 }
93 }
94
95 return true
96}
97
98function ensureDir(dirPath: string): void {
99 if (!fs.existsSync(dirPath)) {

Callers 2

createNodeDataDirSwitchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected