Skip to content
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

Added --only-update option #43

Merged
merged 6 commits into from
May 24, 2019
Merged

Added --only-update option #43

merged 6 commits into from
May 24, 2019

Conversation

Code-Hex
Copy link
Contributor

What

Added --only-update option. use this option, we can update vulnerability database only that we are specified distributions.

Why

If we are creating an docker image based on one distribution (for example, use only alpine image), it is too much to update all DBs. therefore we necessary to wait to update for long time.

@tomoyamachi tomoyamachi requested a review from knqyf263 May 21, 2019 12:00
@tomoyamachi
Copy link
Contributor

LGTM😄

@knqyf263
Copy link
Collaborator

@Code-Hex Thanks! LGTM! However, please wait for a while as we may consider

vulnerability.Ubuntu: ubuntu.Update,
}

func UpdateAll() (err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you commonize UpdateAll() and OnlyUpdate()?

if err = redhat.Update(dir, updatedFiles); err != nil {
return xerrors.Errorf("error in RedHat update: %w", err)
}
func OnlyUpdate(names []string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func OnlyUpdate(names []string) error {
func Update(names []string) error {

pkg/run.go Outdated
if err = vulnsrc.Update(); err != nil {
// this condition is already validated by skipUpdate && onlyUpdate != ""
if onlyUpdate != "" {
if err = vulnsrc.OnlyUpdate(strings.Split(onlyUpdate, ",")); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if err = vulnsrc.OnlyUpdate(strings.Split(onlyUpdate, ",")); err != nil {
if err = vulnsrc.Update(strings.Split(onlyUpdate, ",")); err != nil {

pkg/run.go Outdated
return xerrors.Errorf("error in vulnerability DB update: %w", err)
}
} else {
if err = vulnsrc.UpdateAll(); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if err = vulnsrc.UpdateAll(); err != nil {
if err = vulnsrc.Update(vunerability.DBNames); err != nil {

@Code-Hex
Copy link
Contributor Author

Code-Hex commented May 22, 2019

In this comment

Would you commonize UpdateAll() and OnlyUpdate()?

I have fixed at knqyf263@48ae91e . Is the above means correct in this?

@knqyf263
Copy link
Collaborator

@Code-Hex Thanks! Seems good!
There is one point to notice. Now we are using other databases if there is no vulnerability information in NVD. If you update only the specified database, the severity and title may be empty. Even in that case, it is possible to detect vulnerabilities.
Is that OK?

@Code-Hex
Copy link
Contributor Author

I think no problem. if we feel necessary these, we may use —only-update nvd,alpine .
or we can must enable nvd. What do you think about this?

@knqyf263
Copy link
Collaborator

knqyf263 commented May 22, 2019

@Code-Hex There is no information in NVD, but there may be information in Red Hat DB. So, even if we must enable NVD, there may be no information.

If no data in NVD, trivy uses Red Hat DB.
If no data in Red Hat DB, trivy uses Debian DB.
If no data in Debian DB...

Therefore, it is best to use all DBs. However, if we display a warning, the --only-update option can be adopted.

I'm sorry for asking many times, but would you display a warning if the --update-only option is specified?
The --update-only option may cause the vulnerability details such as severity and title not to be displayed

@Code-Hex
Copy link
Contributor Author

@knqyf263 I'm OK to display warning 👍
Please tell me how should I display message?

BTW, why depends vulnerability information on each databases?
I'm thinking about database should have all vulnerability information of one distribution. For example, database of alpine (alpine-DB) should have alpine vulnerability information and also Information dependent on other distributions.

@knqyf263
Copy link
Collaborator

@Code-Hex Please use log.Logger.Warn().

The vulnerability information of each distribution has two roles in Trivy. The first is vulnerability detection of each distribution. For example, only vulnerability information of Alpine Linux is necessary to detect vulnerabilities in an image of Alpine Linux.

And it is also used when displaying vulnerability details such as a severity and title. The details are different for each distribution.

In the case of CVE-2018-10875:
NVD has the detailed information.
https://nvd.nist.gov/vuln/detail/CVE-2018-10875

However, Alpine Linux has no information.
https://bugs.alpinelinux.org/projects/alpine/search?utf8=✓&scope=subprojects&issues=1&q=CVE-2018-10875

On the other hand, in the case of CVE-2018-5743:
Alpine Linux has the detailed information.
https://bugs.alpinelinux.org/issues/10369

NVD has no information.
https://nvd.nist.gov/vuln/detail/CVE-2018-5743

As mentioned above, it is unknown which distribution has the detailed information. So, Trivy uses all DBs. And when showing vulnerability details, Trivy selects the distribution that has details.

@Code-Hex
Copy link
Contributor Author

@knqyf263 done! please review it.

@knqyf263 knqyf263 merged commit b62536f into aquasecurity:master May 24, 2019
@knqyf263
Copy link
Collaborator

Thanks a lot!!

Mallear pushed a commit to Mallear/trivy that referenced this pull request Jun 6, 2019
* Added --only-update flag

* Added feature for --only-update flag

* Added README of --only-update

* Fixed README

* Use only Update function

* Added warning message
Hardw01f added a commit to Hardw01f/trivy that referenced this pull request Oct 2, 2019
* Added --only-update flag

* Added feature for --only-update flag

* Added README of --only-update

* Fixed README

* Use only Update function

* Added warning message
GuaoGuao pushed a commit to GuaoGuao/trivy that referenced this pull request Jun 24, 2020
* Added --only-update flag

* Added feature for --only-update flag

* Added README of --only-update

* Fixed README

* Use only Update function

* Added warning message
josedonizetti referenced this pull request in josedonizetti/trivy Jun 24, 2022
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.

3 participants