ByteSync icon indicating copy to clipboard operation
ByteSync copied to clipboard

[feature] Block dangerous system paths from inventory sources

Open paul-fresquet opened this issue 10 months ago • 0 comments

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
  • /run and /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:

  1. Display an explicit error message explaining why this path cannot be used
  2. Do not add the path to the session
  3. Log the attempt for debugging purposes

Acceptance Criteria

  • [ ] Create a ProtectedPaths utility 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.

paul-fresquet avatar Feb 01 '26 19:02 paul-fresquet