This repository has been archived by the owner on Feb 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only remove symlinks to vendor dirs on non-Windows OSes
On Windows, we're unable to distinguish between symlinks and junctions. Deleting junctions is dangerous and appears to be able to delete the underlying folder, not just the junction that's pointing to a folder. That's unacceptably dangerous: a malicious repo could contain a junction named 'vendor' pointing at 'C:\\' and we'd delete all the user's data.
- Loading branch information
Showing
7 changed files
with
421 additions
and
225 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//+build !windows | ||
|
||
package gps | ||
|
||
import "os" | ||
|
||
func stripVendor(path string, info os.FileInfo, err error) error { | ||
if info.Name() == "vendor" { | ||
if _, err := os.Lstat(path); err == nil { | ||
if (info.Mode() & os.ModeSymlink) != 0 { | ||
realInfo, err := os.Stat(path) | ||
if err != nil { | ||
return err | ||
} | ||
if realInfo.IsDir() { | ||
return os.Remove(path) | ||
} | ||
} | ||
if info.IsDir() { | ||
return removeAll(path) | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.