Fixes T5300. Adds an ArcanistSymlinkLinter which checks symbolic links.
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Maniphest Tasks
- T5300: Don't lint symbolic links
Created two symbolic links for testing:
>>> Lint for broken: Error (SYMLINK1) Broken Symlink Broken symlinks should not exist. >>> Lint for external: Advice (SYMLINK2) External Symlink Symlinks generally should not point outside of the working copy, for portability reasons.
Diff Detail
- Repository
- rARC Arcanist
- Branch
- symlink-linter
- Lint
Lint Passed - Unit
Tests Passed - Build Status
Buildable 946 Build 946: [Placeholder Plan] Wait for 30 Seconds
Event Timeline
src/lint/linter/ArcanistSymlinkLinter.php | ||
---|---|---|
16 | This could be more descriptive... | |
28 | This linter needs to run before other all other linters... otherwise: Exception Some linters failed: - ArcanistGeneratedLinter: FilesystemException: Requested path `/home/joshua/workspace/github.com/phacility/arcanist/broken' is not a file. - ArcanistNoLintLinter: FilesystemException: Requested path `/home/joshua/workspace/github.com/phacility/arcanist/broken' is not a file. - ArcanistTextLinter: FilesystemException: Requested path `/home/joshua/workspace/github.com/phacility/arcanist/broken' is not a file. - ArcanistSpellingLinter: FilesystemException: Requested path `/home/joshua/workspace/github.com/phacility/arcanist/broken' is not a file. - ArcanistMergeConflictLinter: FilesystemException: Requested path `/home/joshua/workspace/github.com/phacility/arcanist/broken' is not a file. | |
54 | I am not sure how portable this is... i.e. will this work on Windows? | |
59 | As above. |
Per T5300, the cases I can imagine with this are:
- External relative symlinks, like a link in arcanist/ pointed at ../libphutil/src/whatever.php. We don't have any of these in Phabricator (and allow the libraries to be non-adjacent), and this sort of usage is suspicious, but it's more reasonable than putting symlinks to random absolute external files in the working copy.
- In SVN, maybe external relative symlinks leading upwards to nothing present in subtrees?
- Internal symlinks to externals/submodules which haven't been updated.
I don't know how often this stuff will actually happen, but I think broken symlinks are also rare.
Maybe a more practical attack on this is to add shouldLintSymlinks() and default it to false. Let the FilenameLinter run on symlinks, and then this one can exist in some slightly reduced form without needing all the stopAllLinters() stuff and we can see how bad the false positives are?
src/lint/linter/ArcanistSymlinkLinter.php | ||
---|---|---|
31–37 | Maybe we should add shouldLintSymlinks() to this set of special cases. |
src/lint/linter/ArcanistSymlinkLinter.php | ||
---|---|---|
54 | I think this is portable, but see below. | |
59 | Filesystem::pathExists() + readlink($path) might be a better test. $path (which will be relative?) should theoretically be $this->getEngine()->getPathOnDisk($path) (which will produce the correct absolute path?) or something, too, I believe. |