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

Function sensitiveHomeTrees

src/utils.ts:310–327  ·  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

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