MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / isOutsideWorkspace

Method isOutsideWorkspace

daemon/src/service/system_file.ts:46–54  ·  view source on GitHub ↗
(absPath: string)

Source from the content-addressed store, hash-verified

44 }
45
46 private isOutsideWorkspace(absPath: string): boolean {
47 // fix the /app/ vs /app mismatch bug and keep it secure
48 if (this.isRootTopRath()) return false;
49 const realTop = resolveRealPath(this.topPath);
50 const realPath = resolveRealPath(absPath);
51 if (!realTop || !realPath) return true; // If the path cannot be resolved, treat it as outside for safety
52 const relative = path.relative(realTop, realPath);
53 return relative === ".." || relative.startsWith(".." + path.sep) || path.isAbsolute(relative);
54 }
55
56 toAbsolutePath(fileName: string = "") {
57 const topAbsolutePath = this.topPath;

Callers 2

toAbsolutePathMethod · 0.95
assertInsideWorkspaceMethod · 0.95

Calls 2

isRootTopRathMethod · 0.95
resolveRealPathFunction · 0.90

Tested by

no test coverage detected