add alert data to result json (#747)
* add alert data to result json * delete omitempty from AlertDict
This commit is contained in:
		
				
					committed by
					
						
						Kota Kanbe
					
				
			
			
				
	
			
			
			
						parent
						
							9147ec148d
						
					
				
				
					commit
					a5a800fa0a
				
			@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user