From a5a800fa0a93880f79e2ccc4db82aabfa6668f90 Mon Sep 17 00:00:00 2001 From: Tomoya Amachi Date: Wed, 5 Dec 2018 15:38:23 +0900 Subject: [PATCH] add alert data to result json (#747) * add alert data to result json * delete omitempty from AlertDict --- alert/alert_jp.go | 6 +++--- models/vulninfos.go | 6 +++--- report/report.go | 5 +---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/alert/alert_jp.go b/alert/alert_jp.go index c0f9b0d9..6ad4feec 100644 --- a/alert/alert_jp.go +++ b/alert/alert_jp.go @@ -2,9 +2,9 @@ package alert // Alert has XCERT alert information type Alert struct { - URL string - Title string - Team string + URL string `json:"url"` + Title string `json:"title"` + Team string `json:"team"` } // AlertDictJa has JPCERT alerts diff --git a/models/vulninfos.go b/models/vulninfos.go index 1817544d..c46ef924 100644 --- a/models/vulninfos.go +++ b/models/vulninfos.go @@ -170,7 +170,7 @@ type VulnInfo struct { CpeURIs []string `json:"cpeURIs,omitempty"` // CpeURIs related to this CVE defined in config.toml CveContents CveContents `json:"cveContents"` Exploits []Exploit `json:"exploits"` - AlertDict AlertDict `json:"alertDict,omitempty"` + AlertDict AlertDict `json:"alertDict"` } // Titles returns tilte (TUI) @@ -691,8 +691,8 @@ type Exploit struct { // AlertDict has target cve's JPCERT and USCERT alert data type AlertDict struct { - Ja []alert.Alert - En []alert.Alert + Ja []alert.Alert `json:"ja"` + En []alert.Alert `json:"en"` } // HasAlert returns whether or not it has En or Ja entries. diff --git a/report/report.go b/report/report.go index c7725bee..4267d16b 100644 --- a/report/report.go +++ b/report/report.go @@ -389,11 +389,8 @@ func fillCweDict(r *models.ScanResult) { } func fillAlerts(r *models.ScanResult) (enCnt int, jaCnt int) { - enCnt = 0 - jaCnt = 0 for cveID, vuln := range r.ScannedCves { - enAs := models.GetAlertsByCveID(cveID, "en") - jaAs := models.GetAlertsByCveID(cveID, "ja") + enAs, jaAs := models.GetAlertsByCveID(cveID, "en"), models.GetAlertsByCveID(cveID, "ja") vuln.AlertDict = models.AlertDict{ Ja: jaAs, En: enAs,