Closed knqyf263 closed 2 months ago
in source code you use OUT_DIR, but in PR description DB_DIR. Is this the same thing?
Yes. DB dir is used as an argument because it is a DB directory, but I thought output dir would be easier to understand as a CLI flag of trivy-db build
, so that is what I did. I don't mind changing it to the same name.
BTW, I'm afraid of breaking something. I built a database locally and confirmed it worked as expected, but could you double-check it?
Yes. DB dir is used as an argument because it is a DB directory, but I thought output dir would be easier to understand as a CLI flag of trivy-db build, so that is what I did. I don't mind changing it to the same name.
OUT_DIR
is good for me. But I suggest using OUT_DIR
in the PR description so that we don't get confused if we look at that PR later.
I built a database locally and confirmed it worked as expected, but could you double-check it?
I have already build/compress/compact db locally. It works correctly for me too.
OUT_DIR is good for me. But I suggest using OUT_DIR in the PR description so that we don't get confused if we look at that PR later.
Updated.
I have already build/compress/compact db locally. It works correctly for me too.
Awesome. Thanks!
Current Situation
Currently, the db and metadata packages are passed a cache directory, within which they create subdirectories like
$CACHE_DIR/db
. This results in database and metadata files being stored at paths such as:$CACHE_DIR/db/trivy.db
$CACHE_DIR/db/metadata.json
Problem
While the metadata implementation and other aspects are common and potentially reusable for Java DB and other databases, the hard-coded
db/
subdirectory makes it difficult to reuse these packages effectively.Proposed Solution
To improve reusability, I propose to remove the hard-coded
db/
subdirectory and instead allow the DB directory to be passed from outside. This change will result in file paths like:$DB_DIR/trivy.db
$DB_DIR/metadata.json
Where
$DB_DIR
can be set to any desired path, including but not limited to the current$CACHE_DIR/db
.As a CLI flag, the value passed as
--output-dir
is passed directly to $DB_DIR.$OUTPUT_DIR/trivy.db
$OUTPUT_DIR/metadata.json
Note
We need to update Trivy as it also affects Trivy.