refactor(deps): replace archived go-homedir with os.UserHomeDir#10484
Open
kotakanbe wants to merge 2 commits intoaquasecurity:mainfrom
Open
refactor(deps): replace archived go-homedir with os.UserHomeDir#10484kotakanbe wants to merge 2 commits intoaquasecurity:mainfrom
kotakanbe wants to merge 2 commits intoaquasecurity:mainfrom
Conversation
mitchellh/go-homedir has been archived since 2019. Its functionality is fully covered by os.UserHomeDir() (stdlib since Go 1.12). Replace 3 calls to homedir.Expand() with a local expandHome() helper that handles ~/path expansion using os.UserHomeDir() + filepath.Join. The package remains as an indirect dependency via google/go-containerregistry, but the direct import is removed. Detected by uzomuzo (https://github.com/future-architect/uzomuzo-oss), an open-source dependency lifecycle scanner.
Table-driven tests covering: - tilde-only (~) - tilde with forward slash path (~/path) - nested paths (~/a/b/c) - absolute paths (unchanged) - relative paths (unchanged) - empty string (unchanged) - tilde in middle of path (unchanged) - ~username syntax (unchanged, not supported)
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.
Summary
mitchellh/go-homedir(archived since 2019) withos.UserHomeDir()(stdlib, Go 1.12+)homedir.Expand()inpkg/iac/scanners/terraform/parser/funcs/filesystem.goreplaced with a localexpandHome()helperos.UserHomeDir()supports Linux, macOS, and WindowsWhy
mitchellh/go-homedirhas been archived since January 2019. Its author archived it becauseos.UserHomeDir()was added to the Go standard library in Go 1.12, making the package unnecessary.This was detected by uzomuzo, an open-source dependency lifecycle scanner that classifies the package as EOL-Confirmed.
Notes
google/go-containerregistry— this PR removes only the direct importexpandHome()handles~,~/path, and~\path(Windows) — matching the behavior of the originalhomedir.Expand()Test plan
go vet ./pkg/iac/scanners/terraform/parser/funcs/— cleango test ./pkg/iac/scanners/terraform/parser/...— all passgo mod tidy— cleanTestExpandHome— 8 table-driven cases covering tilde expansion, absolute/relative paths, empty string, and edge cases