From fd1429fef0c527829aa2b53a9b52391c109abb8f Mon Sep 17 00:00:00 2001 From: Kota Kanbe Date: Fri, 16 Mar 2018 15:07:26 +0900 Subject: [PATCH] Fix diff logic (#619) * fix: change ControlPath to .vuls of SSH option (#618) * fix: Bug of diff logic --- Gopkg.lock | 2 +- report/util.go | 18 ++++++++++++++---- report/util_test.go | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 0a019e5c..e3ac577c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -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 diff --git a/report/util.go b/report/util.go index f53c4bf8..1dfa27b9 100644 --- a/report/util.go +++ b/report/util.go @@ -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 diff --git a/report/util_test.go b/report/util_test.go index b169820e..d2d3a407 100644 --- a/report/util_test.go +++ b/report/util_test.go @@ -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, },