Skip to content

refactor(deps): replace archived go-homedir with os.UserHomeDir#10484

Open
kotakanbe wants to merge 2 commits intoaquasecurity:mainfrom
kotakanbe:remove-go-homedir
Open

refactor(deps): replace archived go-homedir with os.UserHomeDir#10484
kotakanbe wants to merge 2 commits intoaquasecurity:mainfrom
kotakanbe:remove-go-homedir

Conversation

@kotakanbe
Copy link
Copy Markdown
Contributor

@kotakanbe kotakanbe commented Apr 5, 2026

Summary

  • Replace mitchellh/go-homedir (archived since 2019) with os.UserHomeDir() (stdlib, Go 1.12+)
  • 3 calls to homedir.Expand() in pkg/iac/scanners/terraform/parser/funcs/filesystem.go replaced with a local expandHome() helper
  • Cross-platform: os.UserHomeDir() supports Linux, macOS, and Windows

Why

mitchellh/go-homedir has been archived since January 2019. Its author archived it because os.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

  • The package remains as an indirect dependency via google/go-containerregistry — this PR removes only the direct import
  • expandHome() handles ~, ~/path, and ~\path (Windows) — matching the behavior of the original homedir.Expand()

Test plan

  • go vet ./pkg/iac/scanners/terraform/parser/funcs/ — clean
  • go test ./pkg/iac/scanners/terraform/parser/... — all pass
  • go mod tidy — clean
  • TestExpandHome — 8 table-driven cases covering tilde expansion, absolute/relative paths, empty string, and edge cases

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant