ByteSync
ByteSync copied to clipboard
[feature] Block dangerous system paths from inventory sources
Summary
Prevent users from adding dangerous system paths as data sources in ByteSync. These paths contain special files (devices, pseudo-filesystems) that should never be inventoried or synchronized.
Paths to Block
On Linux/macOS:
/dev— Device files (block/character devices)/proc— Process information pseudo-filesystem/sys— Kernel/device pseudo-filesystem/runand/var/run— Runtime data (sockets, PIDs)
Expected Behavior
When a user attempts to add one of these paths (or a subdirectory) as a data source:
- Display an explicit error message explaining why this path cannot be used
- Do not add the path to the session
- Log the attempt for debugging purposes
Acceptance Criteria
- [ ] Create a
ProtectedPathsutility class to detect dangerous paths - [ ] Integrate path validation in
InventoryBuilder.AddInventoryPart() - [ ] Provide clear, localized error message to the user
- [ ] Unit tests covering path detection (exact match and subdirectories)
- [ ] Works on Linux and macOS (no-op on Windows)
Technical Notes
- Use
Path.GetFullPath()for path normalization before comparison - Consider both exact matches (
/dev) and subdirectories (/dev/sda) - This is a defense-in-depth measure complementing POSIX special file detection
Priority
Critical — Prevents potential hangs or undefined behavior when scanning system directories.