8000 fix: expand db cache dir homedir expressions by kzantow · Pull Request #2600 · anchore/grype · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: expand db cache dir homedir expressions #2600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025
Merged

Conversation

kzantow
Copy link
Contributor
@kzantow kzantow commented Apr 16, 2025

This PR just calls homedir.Expand on the configured DB cache dir. This fixes a longstanding issue that the user's homedir is replaced with ~ in grype config, but not expanded back properly as the user's homedir, but rather a subdirectory (./~).

Example:

$ GRYPE_DB_CACHE_DIR=~/grypedb go run ./cmd/grype alpine:3.15
...
$ ls -l ~/grypedb/6/vulnerability.db
-rw-r--r--@ 1 kzantow  staff  1118699520 Apr 16 08:28 /Users/kzantow/grypedb/6/vulnerability.db

Fixes #2024, #2599

Signed-off-by: Keith Zantow <kzantow@gmail.com>
@kzantow kzantow linked an issue Apr 16, 2025 that may be closed by this pull request
@popey
Copy link
Contributor
popey commented Apr 16, 2025

Works for me!

$ snapshot/darwin-build_darwin_arm64_v8.0/grype config > .grype.yaml
$ grep "~" .grype.yaml
  cache-dir: '~/Library/Caches/grype/db'
$ snapshot/darwin-build_darwin_arm64_v8.0/grype db update
 ✔ Vulnerability DB                [updated]
[0000]  WARN overriding db update check
Vulnerability database updated to latest version!
$ ls -ltrha ~/Library/Caches/grype/db/6/vulnerability.db
-rw-r--r--@ 1 alan  staff   1.0G 16 Apr 14:10 vulnerability.db
$ ls -l "~"
ls: ~: No such file or directory

Copy link
Contributor
@popey popey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WFM & LGTM FWIW THX

@kzantow kzantow merged commit fed6de3 into main Apr 16, 2025
12 checks passed
@kzantow kzantow deleted the fix/expand-cache-dir branch April 16, 2025 15:12
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.

Grype does not handle cache-dir containing ~ correctly Grype should expand ~ in paths in config file
2 participants
0