MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / sensitiveHomeTrees

Function sensitiveHomeTrees

src/utils.ts:311–328  ·  view source on GitHub ↗

* The sensitive home folders, folded: as spelled under the home directory, * under the home's real path (a linked home), and each folder's own real path * (a `~/.ssh` that is itself a link into a dotfiles checkout).

()

Source from the content-addressed store, hash-verified

309 * (a `~/.ssh` that is itself a link into a dotfiles checkout).
310 */
311function sensitiveHomeTrees(): string[] {
312 const home = os.homedir();
313 const now = Date.now();
314 if (sensitiveHomeCache && sensitiveHomeCache.home === home && now < sensitiveHomeCache.expires) {
315 return sensitiveHomeCache.trees;
316 }
317 const trees = new Set<string>();
318 const realHome = nativeRealPath(home);
319 for (const dir of SENSITIVE_HOME_DIRS) {
320 const spelled = path.join(home, dir);
321 trees.add(foldPathCase(spelled));
322 if (realHome) trees.add(foldPathCase(path.join(realHome, dir)));
323 const real = nativeRealPath(spelled);
324 if (real) trees.add(foldPathCase(real));
325 }
326 sensitiveHomeCache = { home, expires: now + SENSITIVE_HOME_TTL_MS, trees: [...trees] };
327 return sensitiveHomeCache.trees;
328}
329
330/**
331 * Validate that a path is a safe project root directory.

Callers 1

Calls 4

nativeRealPathFunction · 0.85
foldPathCaseFunction · 0.85
joinMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected