|
|
@ -225,25 +225,24 @@ func TestInsertVulnerability(t *testing.T) {
|
|
|
|
v1.Description = "TestInsertVulnerabilityLink2"
|
|
|
|
v1.Description = "TestInsertVulnerabilityLink2"
|
|
|
|
v1.Link = "TestInsertVulnerabilityLink2"
|
|
|
|
v1.Link = "TestInsertVulnerabilityLink2"
|
|
|
|
v1.Severity = types.High
|
|
|
|
v1.Severity = types.High
|
|
|
|
// Update f3 in f4, add fixed in f5, add fixed in f6 which already exists, removes fixed in f7 by
|
|
|
|
// Update f3 in f4, add fixed in f5, add fixed in f6 which already exists,
|
|
|
|
// adding f8 which is f7 but with MinVersion.
|
|
|
|
// removes fixed in f7 by adding f8 which is f7 but with MinVersion, and
|
|
|
|
v1.FixedIn = []database.FeatureVersion{f4, f5, f6, f8}
|
|
|
|
// add fixed by f5 a second time (duplicated).
|
|
|
|
|
|
|
|
v1.FixedIn = []database.FeatureVersion{f4, f5, f6, f8, f5}
|
|
|
|
|
|
|
|
|
|
|
|
err = datastore.InsertVulnerabilities([]database.Vulnerability{v1}, true)
|
|
|
|
err = datastore.InsertVulnerabilities([]database.Vulnerability{v1}, true)
|
|
|
|
if assert.Nil(t, err) {
|
|
|
|
if assert.Nil(t, err) {
|
|
|
|
v1f, err := datastore.FindVulnerability(n1.Name, v1.Name)
|
|
|
|
v1f, err := datastore.FindVulnerability(n1.Name, v1.Name)
|
|
|
|
if assert.Nil(t, err) {
|
|
|
|
if assert.Nil(t, err) {
|
|
|
|
|
|
|
|
// Remove f8 from the struct for comparison as it was just here to cancel f7.
|
|
|
|
|
|
|
|
// Remove one of the f5 too as it was twice in the struct but the database
|
|
|
|
|
|
|
|
// implementation should have dedup'd it.
|
|
|
|
|
|
|
|
v1.FixedIn = v1.FixedIn[:len(v1.FixedIn)-2]
|
|
|
|
|
|
|
|
|
|
|
|
// We already had f1 before the update.
|
|
|
|
// We already had f1 before the update.
|
|
|
|
// Add it to the struct for comparison.
|
|
|
|
// Add it to the struct for comparison.
|
|
|
|
v1.FixedIn = append(v1.FixedIn, f1)
|
|
|
|
v1.FixedIn = append(v1.FixedIn, f1)
|
|
|
|
|
|
|
|
|
|
|
|
// Removes f8 from the struct for comparison as it was just here to cancel f7.
|
|
|
|
|
|
|
|
for i := 0; i < len(v1.FixedIn); i++ {
|
|
|
|
|
|
|
|
if v1.FixedIn[i].Feature.Name == f8.Feature.Name {
|
|
|
|
|
|
|
|
v1.FixedIn = append(v1.FixedIn[:i], v1.FixedIn[i+1:]...)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
equalsVuln(t, &v1, &v1f)
|
|
|
|
equalsVuln(t, &v1, &v1f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|