Do not double-prefix symlink paths with base directory when they already contain volume names#2051
Merged
Conversation
Fixes anchore#1950 Co-authored-by: Joseph Palermo <jpalermo@vmware.com> Signed-off-by: Joseph Palermo <jpalermo@vmware.com> Signed-off-by: Chris Selzo <cselzo@vmware.com> Co-authored-by: Chris Selzo <cselzo@vmware.com>
wagoodman
previously approved these changes
Aug 23, 2023
Contributor
wagoodman
left a comment
There was a problem hiding this comment.
Nice fix -- I don't see a good way to get in a test for this given that the expectations would be different for various platforms (and that can't be specified in testing since it's behind filepath package).
Contributor
|
@wagoodman I'm going to give this a look through on my Windows machine |
I'm going to debug through this on Windows before merging
Contributor
Author
|
Great! Yes, I couldn't see a good place to add a test for this. I did verify that it works on a running Windows Server 2019 VM. |
Contributor
This was referenced Aug 28, 2023
Closed
GijsCalis
pushed a commit
to GijsCalis/syft
that referenced
this pull request
Feb 19, 2024
…ames (anchore#2051) Signed-off-by: Joseph Palermo <jpalermo@vmware.com> Signed-off-by: Chris Selzo <cselzo@vmware.com> Co-authored-by: Joseph Palermo <jpalermo@vmware.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We observed that on Windows, symlinks from the
C:\base directory such asC:\Userswere being resolved asC:\C:\Users. In this PR, we do not join the base directory to the resolved symlink if it is already there.On Linux, having a path such as
//usr/local/bindoes not cause any issues (and the//is converted to/infilepath.Clean) butC:\C:\does not work, and is not converted toC:\infilepath.Clean(go playground example)We also noticed that if there is a symlink from the
C:\drive to another drive such asD:\, this code correctly resolves the path, and does not have a path that starts withC:\D:\Fixes #1950 (we think)