Repository navigation
feat(disable symlinks): add --disable-symlinks flag to opt out of symlink support - #5254
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new configuration option and command-line flag, --disable-symlinks (or file-system.disable-symlinks in the configuration file), to disable symbolic link support in GCSFuse. When enabled, creating new symlinks is blocked (returning ENOTSUP), and existing symlink objects in the bucket are treated as regular files instead of symlinks. The changes span configuration parsing, protobuf definitions, filesystem inode logic, documentation, and extensive unit and integration tests. I have no feedback to provide as there are no review comments.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new --disable-symlinks configuration flag to GCSFuse, which blocks the creation of new symlinks (returning ENOTSUP) and treats existing symlink objects as regular files. The changes span configuration parsing, proto definitions, file system operations, and comprehensive testing. The review feedback suggests simplifying the integration test suite structure by directly embedding BaseSymlinkSuite within DisableSymlinksTestSuite to eliminate boilerplate setup and teardown methods.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5254 +/- ##
==========================================
- Coverage 85.11% 85.11% -0.01%
==========================================
Files 181 181
Lines 19848 19861 +13
==========================================
+ Hits 16894 16904 +10
- Misses 2953 2956 +3
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Adds an opt-out flag
--disable-symlinks(config file:file-system: disable-symlinks: true, default:false) to disable symlink support on a GCSFuse mount.In multi-tenant or shared-mount setups where users bring their own bucket, a user could upload a GCS object with symlink metadata pointing to a path on the host machine (e.g.,
/etc/shadow) and read host files outside the mount point.Summary of the code changes:
cfg/params.yaml): Addedfile-system.disable-symlinks(--disable-symlinks, defaultfalse).internal/fs/fs.go):CreateSymlinkandReadSymlinkreturnsyscall.ENOTSUPwhenDisableSymlinksis enabled.internal/fs/fs.go):mintInodeskipsNewSymlinkInodewhenDisableSymlinksis enabled and creates aFileInode(S_IFREG) instead, ensuring the kernel VFS never follows the target path on the host.internal/fs/inode/dir.go,internal/fs/fs.go):ReadEntries(ReadDir) andReadDirPlusreportDT_Fileinstead ofDT_Linkfor symlink objects whenDisableSymlinksis enabled.docs/semantics.md): Documented--disable-symlinksunder the# Symlink inodessection.Link to the issue in case of a bug fix.
b/433488710
Testing details
Executed the below manual test plan comparing default behavior (
--disable-symlinks=false) vs opt-out enabled (--disable-symlinks=true).Created a host file
/tmp/host_secret.txt(outside the mount) and created both a legacy symlink (0Bobject, target ingcsfuse_symlink_targetmetadata) and a standard symlink (20Bobject with target in content +goog-reserved-file-is-symlink=true) pointing to/tmp/host_secret.txt:Verified the comparative behavior across all symlink operations:
--disable-symlinks=false)--disable-symlinks=true)ln -s /tmp/host_secret.txt <MOUNT_DIR>/new_linkOperation not supported(ENOTSUP)ls -l <MOUNT_DIR>lrw-r--r-- ... -> /tmp/host_secret.txt(DT_Link)-rw-r--r--regular files (DT_File), no arrowstat <MOUNT_DIR>/legacy_symlinksymbolic link,Size: 20regular empty file,Size: 0(0BGCS object)stat <MOUNT_DIR>/standard_symlinksymbolic link,Size: 20regular file,Size: 20(20BGCS object content)readlink <MOUNT_DIR>/legacy_symlink/tmp/host_secret.txtEINVAL- not a symlink)readlink <MOUNT_DIR>/standard_symlink/tmp/host_secret.txtEINVAL- not a symlink)cat <MOUNT_DIR>/legacy_symlinkSECRET_HOST_DATA0BGCS object; host untouched)cat <MOUNT_DIR>/standard_symlinkSECRET_HOST_DATA/tmp/host_secret.txtfrom GCS (host untouched)cmd/root_test.go,internal/fs/inode/dir_test.go,internal/fs/disable_symlinks_test.go)TestDisableSymlinksTestSuite(tools/integration_tests/symlink_handling)Any backward incompatible change? If so, please explain.
N/A