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

ROX-6988: Fix RHEL updates by deleting old CVEs when RH advisories are updated #456

Merged
merged 9 commits into from
Aug 30, 2021

Conversation

connorgorman
Copy link
Contributor

No description provided.

@connorgorman connorgorman requested a review from RTann August 19, 2021 19:34
@connorgorman connorgorman requested a review from RTann August 26, 2021 05:26
@connorgorman connorgorman added the generate-dumps-on-pr Generates the image based on dumps from the PR label Aug 26, 2021
@connorgorman
Copy link
Contributor Author

@RTann I cleaned this up. There are 900k fewer vulns in the DB on start. Also, modules are correctly scoped. The vuln creation does delete some CVEs and I think those are expected and are oval issues


func TestRHELv2VulnerabilityCVERemoval(t *testing.T) {
datastore, err := openDatabaseForTest("TestRHELv2VulnerabilityCVERemoval", false)
if 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.

require.NoError(t, err)

Copy link
Collaborator

Choose a reason for hiding this comment

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

you fixed a separate one but not this one lol

CVEs: []string{"CVE-2021-1234", "CVE-2021-1235"},
}

err = datastore.InsertRHELv2Vulnerabilities([]*database.RHELv2Vulnerability{v3})
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens if i insert all 3 cves in this call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the vulnerability is added after the RHSA then it will be in the DB. Realistically, this shouldn't happen though because the RHSAs and CVEs should not overlap and mostly this is the case as seen through the genesis dump

}
}
for module, packages := range packagesByModule {
result, err := vulnDeleteStatement.Exec(pq.Array(vuln.CVEs), pq.Array(packages), pq.Array(vuln.CPEs), module)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm still curious if it's possible we find a value in this cross-product that is in the DB but should not actually be deleted. Is that possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went through the genesis dump vulns that were printed and they all looked like they should be legitimately removed. My understanding of the code (you would know better) is that we'll be inserting an RHSA with all the packages and cpes so the vulns will match against that. I would not expect both an RHSA and CVE to match on the same package and cpe if the RHSA fixes that CVE

cris := cris[:0]
walkCriterion(&def.Criteria, &cris)
enabledModules := getEnabledModules(cris)
Copy link
Collaborator

Choose a reason for hiding this comment

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

so before we'd get all the modules mentions in the CVE and attribute them to each package? Now we are only attributing the module relevant to the package? We should sync with Hank since this is in claircore as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is not correct because the criterions AND the module and the packages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, we were deleting too many things prior to this change

Copy link
Collaborator

Choose a reason for hiding this comment

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

makes me concerned we were inserting entries into the DB that should have never existed. At least, they won't match any vulnerabilities (I don't think), so not the end of the world. But rather, potentially, wasteful, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we were inserting entries that should never have existed, but honestly not very many

@connorgorman connorgorman requested a review from RTann August 27, 2021 19:23
cris := cris[:0]
walkCriterion(&def.Criteria, &cris)
enabledModules := getEnabledModules(cris)
Copy link
Collaborator

Choose a reason for hiding this comment

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

makes me concerned we were inserting entries into the DB that should have never existed. At least, they won't match any vulnerabilities (I don't think), so not the end of the world. But rather, potentially, wasteful, no?


func TestRHELv2VulnerabilityCVERemoval(t *testing.T) {
datastore, err := openDatabaseForTest("TestRHELv2VulnerabilityCVERemoval", false)
if 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.

you fixed a separate one but not this one lol

@connorgorman connorgorman requested a review from RTann August 27, 2021 20:31
Copy link
Collaborator

@RTann RTann left a comment

Choose a reason for hiding this comment

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

how do the logs look for older scanners? any errors?

@connorgorman connorgorman merged commit 5c797b7 into master Aug 30, 2021
@connorgorman connorgorman deleted the cgorman-rhel branch August 30, 2021 19:52
@connorgorman connorgorman changed the title Fix RHEL updates by deleting old CVEs when RH advisories are updated ROX-6988: Fix RHEL updates by deleting old CVEs when RH advisories are updated Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generate-dumps-on-pr Generates the image based on dumps from the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants