MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / isPathSafe

Function isPathSafe

apps/desktop/main/utils/pathUtils.ts:45–56  ·  view source on GitHub ↗
(targetPath: string)

Source from the content-addressed store, hash-verified

43 * 检查路径是否安全(不在系统关键目录下)
44 */
45export function isPathSafe(targetPath: string): boolean {
46 const normalizedTarget = targetPath.toLowerCase().replace(/\//g, '\\')
47
48 for (const dangerous of DANGEROUS_PATHS) {
49 const normalizedDangerous = dangerous.toLowerCase().replace(/\//g, '\\')
50 if (normalizedTarget.startsWith(normalizedDangerous)) {
51 return false
52 }
53 }
54
55 return true
56}
57
58/**
59 * 检查目录是否为空或包含 ChatLab 标记与关键结构

Callers 2

setCustomDataDirFunction · 0.90
cleanupPendingDeleteDirFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected