Fix diff logic (#619)
* fix: change ControlPath to .vuls of SSH option (#618) * fix: Bug of diff logic
This commit is contained in:
2
Gopkg.lock
generated
2
Gopkg.lock
generated
@@ -383,6 +383,6 @@
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "17ca5502a80ae70140ecf819a5b2757898b42deca821221afebce63488b691ea"
|
||||
inputs-digest = "6f9e0e0abf431f853507394b28b24360e764850217a4bc8e6bdf300b34891dd2"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
||||
@@ -344,11 +344,14 @@ func getDiffCves(previous, current models.ScanResult) models.VulnInfos {
|
||||
updated := models.VulnInfos{}
|
||||
for _, v := range current.ScannedCves {
|
||||
if previousCveIDsSet[v.CveID] {
|
||||
if isCveInfoUpdated(v.CveID, previous, current) || isCveFixed(v, previous) {
|
||||
if isCveInfoUpdated(v.CveID, previous, current) {
|
||||
updated[v.CveID] = v
|
||||
util.Log.Debugf("updated or new release: %s", v.CveID)
|
||||
util.Log.Debugf("updated: %s", v.CveID)
|
||||
} else if isCveFixed(v, previous) {
|
||||
updated[v.CveID] = v
|
||||
util.Log.Debugf("fixed: %s", v.CveID)
|
||||
} else {
|
||||
util.Log.Debugf("same and not new Release: %s", v.CveID)
|
||||
util.Log.Debugf("same: %s", v.CveID)
|
||||
}
|
||||
} else {
|
||||
util.Log.Debugf("new: %s", v.CveID)
|
||||
@@ -406,7 +409,14 @@ func isCveInfoUpdated(cveID string, previous, current models.ScanResult) bool {
|
||||
}
|
||||
}
|
||||
|
||||
return !reflect.DeepEqual(curLastModified, prevLastModified)
|
||||
for _, t := range cTypes {
|
||||
if !curLastModified[t].Equal(prevLastModified[t]) {
|
||||
util.Log.Debugf("%s LastModified not equal: \n%s\n%s",
|
||||
cveID, curLastModified[t], prevLastModified[t])
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// jsonDirPattern is file name pattern of JSON directory
|
||||
|
||||
@@ -77,7 +77,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
|
||||
CveID: "CVE-2017-0002",
|
||||
CveContents: models.NewCveContents(
|
||||
models.CveContent{
|
||||
Type: models.NVD,
|
||||
Type: models.JVN,
|
||||
CveID: "CVE-2017-0002",
|
||||
LastModified: old,
|
||||
},
|
||||
@@ -91,7 +91,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
|
||||
CveID: "CVE-2017-0002",
|
||||
CveContents: models.NewCveContents(
|
||||
models.CveContent{
|
||||
Type: models.NVD,
|
||||
Type: models.JVN,
|
||||
CveID: "CVE-2017-0002",
|
||||
LastModified: old,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user