From a8c0926b4f674b3a56de06a6489ef51a6131eae1 Mon Sep 17 00:00:00 2001 From: sadayuki-matsuno Date: Wed, 27 Jan 2021 14:43:09 +0900 Subject: [PATCH 1/2] fix(saas) change saas upload s3 key (#1116) --- saas/saas.go | 10 +++++++++- saas/uuid.go | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/saas/saas.go b/saas/saas.go index eb46cca1..a7a78063 100644 --- a/saas/saas.go +++ b/saas/saas.go @@ -3,6 +3,7 @@ package saas import ( "bytes" "encoding/json" + "fmt" "io/ioutil" "net/http" "net/url" @@ -120,7 +121,7 @@ func (w Writer) Write(rs ...models.ScanResult) (err error) { svc := s3.New(sess) for _, r := range rs { - s3Key := renameKeyNameUTC(r.ScannedAt, r.ServerUUID, r.Container) + s3Key := renameKeyName(r.ServerUUID, r.Container) var b []byte if b, err = json.Marshal(r); err != nil { return xerrors.Errorf("Failed to Marshal to JSON: %w", err) @@ -140,3 +141,10 @@ func (w Writer) Write(rs ...models.ScanResult) (err error) { util.Log.Infof("done") return nil } + +func renameKeyName(uuid string, container models.Container) string { + if len(container.ContainerID) == 0 { + return fmt.Sprintf("%s.json", uuid) + } + return fmt.Sprintf("%s@%s.json", container.UUID, uuid) +} diff --git a/saas/uuid.go b/saas/uuid.go index c44051f1..f1bf1d87 100644 --- a/saas/uuid.go +++ b/saas/uuid.go @@ -9,7 +9,6 @@ import ( "regexp" "sort" "strings" - "time" "github.com/BurntSushi/toml" c "github.com/future-architect/vuls/config" @@ -19,14 +18,6 @@ import ( "golang.org/x/xerrors" ) -func renameKeyNameUTC(scannedAt time.Time, uuid string, container models.Container) string { - timestr := scannedAt.UTC().Format(time.RFC3339) - if len(container.ContainerID) == 0 { - return fmt.Sprintf("%s/%s.json", timestr, uuid) - } - return fmt.Sprintf("%s/%s@%s.json", timestr, container.UUID, uuid) -} - const reUUID = "[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}" // Scanning with the -containers-only flag at scan time, the UUID of Container Host may not be generated, From 3dbdd01f9786d51eb25a168321ed07c4c725a451 Mon Sep 17 00:00:00 2001 From: Kota Kanbe Date: Thu, 28 Jan 2021 08:24:03 +0900 Subject: [PATCH 2/2] fix(report): wordrpess scanning skipped when package is emtpy (#1150) --- config/config.go | 2 +- report/report.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index ed7f0081..c3fd300c 100644 --- a/config/config.go +++ b/config/config.go @@ -339,7 +339,7 @@ type AzureConf struct { // WpScanConf is wpscan.com config type WpScanConf struct { - Token string `toml:"Token,omitempty" json:"-"` + Token string `toml:"token,omitempty" json:"-"` DetectInactive bool `toml:"detectInactive,omitempty" json:"detectInactive,omitempty"` } diff --git a/report/report.go b/report/report.go index c0fefab8..19fc433c 100644 --- a/report/report.go +++ b/report/report.go @@ -227,7 +227,7 @@ func DetectGitHubCves(r *models.ScanResult, githubConfs map[string]c.GitHubConf) // DetectWordPressCves detects CVEs of WordPress func DetectWordPressCves(r *models.ScanResult, wpCnf *c.WpScanConf) error { - if len(r.Packages) == 0 { + if len(r.WordPressPackages) == 0 { return nil } util.Log.Infof("Detect WordPress CVE. pkgs: %d ", len(r.WordPressPackages))