add alert data to result json (#747)

* add alert data to result json

* delete omitempty from AlertDict
This commit is contained in:
Tomoya Amachi
2018-12-05 15:38:23 +09:00
committed by Kota Kanbe
parent 9147ec148d
commit a5a800fa0a
3 changed files with 7 additions and 10 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -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,