Include config in json result

This commit is contained in:
kota kanbe
2017-08-18 22:39:45 +09:00
parent 71490aebd9
commit 648a999514
4 changed files with 20 additions and 4 deletions

View File

@@ -110,7 +110,7 @@ type Config struct {
S3ResultsDir string
AzureAccount string
AzureKey string
AzureKey string `json:"-"`
AzureContainer string
Pipe bool
@@ -300,7 +300,7 @@ type SMTPConf struct {
SMTPPort string `valid:"port"`
User string
Password string
Password string `json:"-"`
From string
To []string
Cc []string
@@ -360,7 +360,7 @@ func (c *SMTPConf) Validate() (errs []error) {
// SlackConf is slack config
type SlackConf struct {
HookURL string `valid:"url"`
HookURL string `valid:"url" json:"-"`
Channel string `json:"channel"`
IconEmoji string `json:"icon_emoji"`
AuthUser string `json:"username"`
@@ -410,7 +410,7 @@ type ServerInfo struct {
Host string
Port string
KeyPath string
KeyPassword string
KeyPassword string `json:"-"`
CpeNames []string
DependencyCheckXMLPath string

View File

@@ -21,6 +21,8 @@ import (
"bytes"
"fmt"
"time"
"github.com/future-architect/vuls/config"
)
// ScanResults is a slide of ScanResult
@@ -29,6 +31,7 @@ type ScanResults []ScanResult
// ScanResult has the result of scanned CVE information.
type ScanResult struct {
ScannedAt time.Time
ReportedAt time.Time
JSONVersion int
Lang string
ServerUUID string
@@ -44,6 +47,11 @@ type ScanResult struct {
Packages Packages
Errors []string
Optional [][]interface{}
Config struct {
Scan config.Config
Report config.Config
}
}
// FilterByCvssOver is filter function.

View File

@@ -20,6 +20,7 @@ package report
import (
"fmt"
"strings"
"time"
c "github.com/future-architect/vuls/config"
"github.com/future-architect/vuls/models"
@@ -35,12 +36,18 @@ const (
// FillCveInfos fills CVE Detailed Information
func FillCveInfos(rs []models.ScanResult, dir string) ([]models.ScanResult, error) {
var filled []models.ScanResult
reportedAt := time.Now()
for _, r := range rs {
if c.Conf.RefreshCve || needToRefreshCve(r) {
if err := fillCveInfo(&r); err != nil {
return nil, err
}
r.Lang = c.Conf.Lang
r.ReportedAt = reportedAt
r.Config.Report = c.Conf
r.Config.Report.Servers = map[string]c.ServerInfo{
r.ServerName: c.Conf.Servers[r.ServerName],
}
if err := overwriteJSONFile(dir, r); err != nil {
return nil, fmt.Errorf("Failed to write JSON: %s", err)
}

View File

@@ -449,6 +449,7 @@ func scanVulns(jsonDir string, scannedAt time.Time, timeoutSec int) error {
for _, s := range append(servers, errServers...) {
r := s.convertToModel()
r.ScannedAt = scannedAt
r.Config.Scan = config.Conf
results = append(results, r)
}