DashboardcraftgetWorkspaceGlobMatches symlink contain…

getWorkspaceGlobMatches symlink containment and realpath errors

Category: gotcha
Confidence: 1.00
ID: 01a0820f-ad85-75ab-b39b-f4e36216643e
Project ID: e16af391-c497-4837-b681-c849a5514499
Cross-project: No
Recalled in other projects: 0
Source session: 1Okgn0vvN7hdZmhlc
Created: 2026-09-08 17:25:08
Updated: 2026-09-08 17:27:40

Content

Trap: lexical workspace-root checks after globSync() look sufficient, but glob emits broken-symlink candidates and symlinks can physically escape the repository. Fix: validate each match as a safe path and lexically contained, then realpathSync() it and require containment under the real root plus lstatSync(...).isDirectory(). Skip only ENOENT from realpathSync() (a vanished or broken link); rethrow ELOOP, EACCES, EPERM, I/O, and programming errors so unsafe filesystem state is never masked. Keep sorted results. Regression tests must prove installed glob emits the broken link, exclude it, and prove an ELOOP link propagates.

Move to: