aquasecurity / trivy

Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more
https://aquasecurity.github.io/trivy
Apache License 2.0
22.14k stars 2.18k forks source link

feat!: add clean subcommand #6993

Closed knqyf263 closed 2 weeks ago

knqyf263 commented 2 weeks ago

Description

Delete cache management flags and add trivy clean.

Clear all caches

Before

$ trivy image --reset

After

$ trivy clean --all

Clear scan cache

Before

$ trivy image --clear-cache

After

$ trivy clean --scan-cache

Clear checks bundle

Before

$ trivy config --reset-checks-bundle

After

$ trivy clean --checks-bundle

Clear vulnerability database

Before

N/A (trivy image --reset removes all)

After

$ trivy clean --vuln-db

Clear Java database

Before

N/A (trivy image --reset removes all)

After

$ trivy clean --java-db

Related issues

Checklist

knqyf263 commented 2 weeks ago

2024-06-24T11:18:41+06:00 ERROR "--reset" was removed. Use "trivy clean --all" instead. 2024-06-24T11:18:41+06:00 FATAL Fatal error flag error: db flag error: unable to parse flag: "--reset" was removed

I returned Use "trivy clean --all" instead as an error, but it appears at the end of the log message and is therefore difficult to find as below.

2024-06-24T11:18:41+06:00 FATAL Fatal error flag error: db flag error: unable to parse flag: "--reset" was removed. use "trivy clean --all" instead.

I eventually separated the error message. In short, it's intended.

If you don't like "--reset" was removed. is displayed twice, I can change the error message.

DmitriyLewen commented 2 weeks ago

I eventually separated the error message. In short, it's intended.

Got it :smile: Then no problem :+1:

knqyf263 commented 2 weeks ago

@DmitriyLewen I change the message slightly. https://github.com/aquasecurity/trivy/pull/6993/commits/5a989d4fc203a5cc14ab27a2ef3877a6d871f6c0

knqyf263 commented 2 weeks ago

@simar7 @nikpivkin According to the discussion in https://github.com/aquasecurity/trivy/issues/6992, I didn't add --terraform-module flag. If you want to move the cache under the Trivy cache directory and let Trivy delete the cache, please feel free to open a new PR. I don't think it's a blocker of this PR.

DmitriyLewen commented 2 weeks ago

@knqyf263 I understand that didn't write about comments for --reset-checks-bundle flag. Added in https://github.com/aquasecurity/trivy/pull/6993/commits/8995644c6690425982c6c0a55d60864effc7147f

knqyf263 commented 2 weeks ago

@DmitriyLewen Thanks! It's my bad.

knqyf263 commented 2 weeks ago

@chen-keinan @simar7 @nikpivkin Since it's a breaking change, I'd wait for you guys.

knqyf263 commented 2 weeks ago

Announced https://github.com/aquasecurity/trivy/discussions/7010