* 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).
()
| 308 | * (a `~/.ssh` that is itself a link into a dotfiles checkout). |
| 309 | */ |
| 310 | function 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. |
no test coverage detected