Change models structure
This commit is contained in:
@@ -139,13 +139,9 @@ func createBlockBlob(cli storage.BlobStorageClient, k string, b []byte) error {
|
||||
k = k + ".gz"
|
||||
}
|
||||
|
||||
if err := cli.CreateBlockBlobFromReader(
|
||||
c.Conf.AzureContainer,
|
||||
k,
|
||||
uint64(len(b)),
|
||||
bytes.NewReader(b),
|
||||
map[string]string{},
|
||||
); err != nil {
|
||||
ref := cli.GetContainerReference(c.Conf.AzureContainer)
|
||||
blob := ref.GetBlobReference(k)
|
||||
if err := blob.CreateBlockBlobFromReader(bytes.NewReader(b), nil); err != nil {
|
||||
return fmt.Errorf("Failed to upload data to %s/%s, %s",
|
||||
c.Conf.AzureContainer, k, err)
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ func (w EMailWriter) Write(rs ...models.ScanResult) (err error) {
|
||||
for _, r := range rs {
|
||||
if conf.FormatOneEMail {
|
||||
message += formatFullPlainText(r) + "\r\n\r\n"
|
||||
totalResult.KnownCves = append(totalResult.KnownCves, r.KnownCves...)
|
||||
totalResult.UnknownCves = append(totalResult.UnknownCves, r.UnknownCves...)
|
||||
// totalResult.KnownCves = append(totalResult.KnownCves, r.KnownCves...)
|
||||
// totalResult.UnknownCves = append(totalResult.UnknownCves, r.UnknownCves...)
|
||||
} else {
|
||||
var subject string
|
||||
if len(r.Errors) != 0 {
|
||||
|
||||
236
report/slack.go
236
report/slack.go
@@ -21,7 +21,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
@@ -67,11 +66,12 @@ func (w SlackWriter) Write(rs ...models.ScanResult) error {
|
||||
}
|
||||
|
||||
if 0 < len(r.Errors) {
|
||||
serverInfo := fmt.Sprintf("*%s*", r.ServerInfo())
|
||||
notifyUsers := getNotifyUsers(config.Conf.Slack.NotifyUsers)
|
||||
txt := fmt.Sprintf("%s\n%s\nError: %s", notifyUsers, serverInfo, r.Errors)
|
||||
//TODO
|
||||
// serverInfo := fmt.Sprintf("*%s*", r.ServerInfo())
|
||||
// notifyUsers := getNotifyUsers(config.Conf.Slack.NotifyUsers)
|
||||
// txt := fmt.Sprintf("%s\n%s\nError: %s", notifyUsers, serverInfo, r.Errors)
|
||||
msg := message{
|
||||
Text: txt,
|
||||
// Text: txt,
|
||||
Username: conf.AuthUser,
|
||||
IconEmoji: conf.IconEmoji,
|
||||
Channel: channel,
|
||||
@@ -152,57 +152,57 @@ func send(msg message) error {
|
||||
|
||||
func msgText(r models.ScanResult) string {
|
||||
notifyUsers := ""
|
||||
if 0 < len(r.KnownCves) || 0 < len(r.UnknownCves) {
|
||||
notifyUsers = getNotifyUsers(config.Conf.Slack.NotifyUsers)
|
||||
}
|
||||
// if 0 < len(r.KnownCves) || 0 < len(r.UnknownCves) {
|
||||
// notifyUsers = getNotifyUsers(config.Conf.Slack.NotifyUsers)
|
||||
// }
|
||||
serverInfo := fmt.Sprintf("*%s*", r.ServerInfo())
|
||||
return fmt.Sprintf("%s\n%s\n>%s", notifyUsers, serverInfo, r.CveSummary())
|
||||
}
|
||||
|
||||
func toSlackAttachments(scanResult models.ScanResult) (attaches []*attachment) {
|
||||
cves := scanResult.KnownCves
|
||||
if !config.Conf.IgnoreUnscoredCves {
|
||||
cves = append(cves, scanResult.UnknownCves...)
|
||||
}
|
||||
// cves := scanResult.KnownCves
|
||||
// if !config.Conf.IgnoreUnscoredCves {
|
||||
// cves = append(cves, scanResult.UnknownCves...)
|
||||
// }
|
||||
|
||||
for _, cveInfo := range cves {
|
||||
cveID := cveInfo.VulnInfo.CveID
|
||||
// for _, cveInfo := range cves {
|
||||
// cveID := cveInfo.VulnInfo.CveID
|
||||
|
||||
curentPackages := []string{}
|
||||
for _, p := range cveInfo.Packages {
|
||||
curentPackages = append(curentPackages, p.FormatCurrentVer())
|
||||
}
|
||||
for _, n := range cveInfo.CpeNames {
|
||||
curentPackages = append(curentPackages, n)
|
||||
}
|
||||
// curentPackages := []string{}
|
||||
// for _, p := range cveInfo.Packages {
|
||||
// curentPackages = append(curentPackages, p.FormatCurrentVer())
|
||||
// }
|
||||
// for _, n := range cveInfo.CpeNames {
|
||||
// curentPackages = append(curentPackages, n)
|
||||
// }
|
||||
|
||||
newPackages := []string{}
|
||||
for _, p := range cveInfo.Packages {
|
||||
newPackages = append(newPackages, p.FormatNewVer())
|
||||
}
|
||||
// newPackages := []string{}
|
||||
// for _, p := range cveInfo.Packages {
|
||||
// newPackages = append(newPackages, p.FormatNewVer())
|
||||
// }
|
||||
|
||||
a := attachment{
|
||||
Title: cveID,
|
||||
TitleLink: fmt.Sprintf("%s/%s", nvdBaseURL, cveID),
|
||||
Text: attachmentText(cveInfo, scanResult.Family),
|
||||
MrkdwnIn: []string{"text", "pretext"},
|
||||
Fields: []*field{
|
||||
{
|
||||
// Title: "Current Package/CPE",
|
||||
Title: "Installed",
|
||||
Value: strings.Join(curentPackages, "\n"),
|
||||
Short: true,
|
||||
},
|
||||
{
|
||||
Title: "Candidate",
|
||||
Value: strings.Join(newPackages, "\n"),
|
||||
Short: true,
|
||||
},
|
||||
},
|
||||
Color: color(cveInfo.CvssV2Score()),
|
||||
}
|
||||
attaches = append(attaches, &a)
|
||||
}
|
||||
// a := attachment{
|
||||
// Title: cveID,
|
||||
// TitleLink: fmt.Sprintf("%s/%s", nvdBaseURL, cveID),
|
||||
// Text: attachmentText(cveInfo, scanResult.Family),
|
||||
// MrkdwnIn: []string{"text", "pretext"},
|
||||
// Fields: []*field{
|
||||
// {
|
||||
// // Title: "Current Package/CPE",
|
||||
// Title: "Installed",
|
||||
// Value: strings.Join(curentPackages, "\n"),
|
||||
// Short: true,
|
||||
// },
|
||||
// {
|
||||
// Title: "Candidate",
|
||||
// Value: strings.Join(newPackages, "\n"),
|
||||
// Short: true,
|
||||
// },
|
||||
// },
|
||||
// Color: color(cveInfo.CvssV2Score()),
|
||||
// }
|
||||
// attaches = append(attaches, &a)
|
||||
// }
|
||||
return
|
||||
}
|
||||
|
||||
@@ -220,80 +220,80 @@ func color(cvssScore float64) string {
|
||||
}
|
||||
}
|
||||
|
||||
func attachmentText(cveInfo models.CveInfo, osFamily string) string {
|
||||
// linkText := links(cveInfo, osFamily)
|
||||
//TODO
|
||||
return ""
|
||||
// switch {
|
||||
// case config.Conf.Lang == "ja" &&
|
||||
// 0 < cveInfo.CveDetail.Jvn.CvssScore():
|
||||
// func attachmentText(cveInfo models.CveInfo, osFamily string) string {
|
||||
// linkText := links(cveInfo, osFamily)
|
||||
//TODO
|
||||
// return ""
|
||||
// switch {
|
||||
// case config.Conf.Lang == "ja" &&
|
||||
// 0 < cveInfo.CveDetail.Jvn.CvssScore():
|
||||
|
||||
// jvn := cveInfo.CveDetail.Jvn
|
||||
// return fmt.Sprintf("*%4.1f (%s)* <%s|%s>\n%s\n%s\n*Confidence:* %v",
|
||||
// cveInfo.CveDetail.CvssScore(config.Conf.Lang),
|
||||
// jvn.CvssSeverity(),
|
||||
// fmt.Sprintf(cvssV2CalcBaseURL, cveInfo.CveDetail.CveID),
|
||||
// jvn.CvssVector(),
|
||||
// jvn.CveTitle(),
|
||||
// linkText,
|
||||
// cveInfo.VulnInfo.Confidence,
|
||||
// )
|
||||
// case 0 < cveInfo.CveDetail.CvssScore("en"):
|
||||
// nvd := cveInfo.CveDetail.Nvd
|
||||
// return fmt.Sprintf("*%4.1f (%s)* <%s|%s>\n%s\n%s\n*Confidence:* %v",
|
||||
// cveInfo.CveDetail.CvssScore(config.Conf.Lang),
|
||||
// nvd.CvssSeverity(),
|
||||
// fmt.Sprintf(cvssV2CalcBaseURL, cveInfo.CveDetail.CveID),
|
||||
// nvd.CvssVector(),
|
||||
// nvd.CveSummary(),
|
||||
// linkText,
|
||||
// cveInfo.VulnInfo.Confidence,
|
||||
// )
|
||||
// default:
|
||||
// nvd := cveInfo.CveDetail.Nvd
|
||||
// return fmt.Sprintf("?\n%s\n%s\n*Confidence:* %v",
|
||||
// nvd.CveSummary(), linkText, cveInfo.VulnInfo.Confidence)
|
||||
// }
|
||||
}
|
||||
// jvn := cveInfo.CveDetail.Jvn
|
||||
// return fmt.Sprintf("*%4.1f (%s)* <%s|%s>\n%s\n%s\n*Confidence:* %v",
|
||||
// cveInfo.CveDetail.CvssScore(config.Conf.Lang),
|
||||
// jvn.CvssSeverity(),
|
||||
// fmt.Sprintf(cvssV2CalcBaseURL, cveInfo.CveDetail.CveID),
|
||||
// jvn.CvssVector(),
|
||||
// jvn.CveTitle(),
|
||||
// linkText,
|
||||
// cveInfo.VulnInfo.Confidence,
|
||||
// )
|
||||
// case 0 < cveInfo.CveDetail.CvssScore("en"):
|
||||
// nvd := cveInfo.CveDetail.Nvd
|
||||
// return fmt.Sprintf("*%4.1f (%s)* <%s|%s>\n%s\n%s\n*Confidence:* %v",
|
||||
// cveInfo.CveDetail.CvssScore(config.Conf.Lang),
|
||||
// nvd.CvssSeverity(),
|
||||
// fmt.Sprintf(cvssV2CalcBaseURL, cveInfo.CveDetail.CveID),
|
||||
// nvd.CvssVector(),
|
||||
// nvd.CveSummary(),
|
||||
// linkText,
|
||||
// cveInfo.VulnInfo.Confidence,
|
||||
// )
|
||||
// default:
|
||||
// nvd := cveInfo.CveDetail.Nvd
|
||||
// return fmt.Sprintf("?\n%s\n%s\n*Confidence:* %v",
|
||||
// nvd.CveSummary(), linkText, cveInfo.VulnInfo.Confidence)
|
||||
// }
|
||||
// }
|
||||
|
||||
func links(cveInfo models.CveInfo, osFamily string) string {
|
||||
links := []string{}
|
||||
// func links(cveInfo models.CveInfo, osFamily string) string {
|
||||
// links := []string{}
|
||||
|
||||
//TODO
|
||||
// cweID := cveInfo.CveDetail.CweID()
|
||||
// if 0 < len(cweID) {
|
||||
// links = append(links, fmt.Sprintf("<%s|%s>",
|
||||
// cweURL(cweID), cweID))
|
||||
// if config.Conf.Lang == "ja" {
|
||||
// links = append(links, fmt.Sprintf("<%s|%s(JVN)>",
|
||||
// cweJvnURL(cweID), cweID))
|
||||
// }
|
||||
// }
|
||||
// //TODO
|
||||
// // cweID := cveInfo.CveDetail.CweID()
|
||||
// // if 0 < len(cweID) {
|
||||
// // links = append(links, fmt.Sprintf("<%s|%s>",
|
||||
// // cweURL(cweID), cweID))
|
||||
// // if config.Conf.Lang == "ja" {
|
||||
// // links = append(links, fmt.Sprintf("<%s|%s(JVN)>",
|
||||
// // cweJvnURL(cweID), cweID))
|
||||
// // }
|
||||
// // }
|
||||
|
||||
cveID := cveInfo.VulnInfo.CveID
|
||||
//TODO
|
||||
// if config.Conf.Lang == "ja" && 0 < len(cveInfo.CveDetail.Jvn.Link()) {
|
||||
// jvn := fmt.Sprintf("<%s|JVN>", cveInfo.CveDetail.Jvn.Link())
|
||||
// links = append(links, jvn)
|
||||
// }
|
||||
dlinks := distroLinks(cveInfo, osFamily)
|
||||
for _, link := range dlinks {
|
||||
links = append(links,
|
||||
fmt.Sprintf("<%s|%s>", link.url, link.title))
|
||||
}
|
||||
links = append(links, fmt.Sprintf("<%s|MITRE>",
|
||||
fmt.Sprintf("%s%s", mitreBaseURL, cveID)))
|
||||
links = append(links, fmt.Sprintf("<%s|CVEDetails>",
|
||||
fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID)))
|
||||
// cveID := cveInfo.VulnInfo.CveID
|
||||
// //TODO
|
||||
// // if config.Conf.Lang == "ja" && 0 < len(cveInfo.CveDetail.Jvn.Link()) {
|
||||
// // jvn := fmt.Sprintf("<%s|JVN>", cveInfo.CveDetail.Jvn.Link())
|
||||
// // links = append(links, jvn)
|
||||
// // }
|
||||
// dlinks := distroLinks(cveInfo, osFamily)
|
||||
// for _, link := range dlinks {
|
||||
// links = append(links,
|
||||
// fmt.Sprintf("<%s|%s>", link.url, link.title))
|
||||
// }
|
||||
// links = append(links, fmt.Sprintf("<%s|MITRE>",
|
||||
// fmt.Sprintf("%s%s", mitreBaseURL, cveID)))
|
||||
// links = append(links, fmt.Sprintf("<%s|CVEDetails>",
|
||||
// fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID)))
|
||||
|
||||
return strings.Join(links, " / ")
|
||||
}
|
||||
// return strings.Join(links, " / ")
|
||||
// }
|
||||
|
||||
// See testcase
|
||||
func getNotifyUsers(notifyUsers []string) string {
|
||||
slackStyleTexts := []string{}
|
||||
for _, username := range notifyUsers {
|
||||
slackStyleTexts = append(slackStyleTexts, fmt.Sprintf("<%s>", username))
|
||||
}
|
||||
return strings.Join(slackStyleTexts, " ")
|
||||
}
|
||||
// // See testcase
|
||||
// func getNotifyUsers(notifyUsers []string) string {
|
||||
// slackStyleTexts := []string{}
|
||||
// for _, username := range notifyUsers {
|
||||
// slackStyleTexts = append(slackStyleTexts, fmt.Sprintf("<%s>", username))
|
||||
// }
|
||||
// return strings.Join(slackStyleTexts, " ")
|
||||
// }
|
||||
|
||||
271
report/tui.go
271
report/tui.go
@@ -22,7 +22,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
@@ -221,7 +220,8 @@ func movable(v *gocui.View, nextY int) (ok bool, yLimit int) {
|
||||
}
|
||||
return true, yLimit
|
||||
case "summary":
|
||||
yLimit = len(currentScanResult.AllCves()) - 1
|
||||
//TODO
|
||||
// yLimit = len(currentScanResult.AllCves()) - 1
|
||||
if yLimit < nextY {
|
||||
return false, yLimit
|
||||
}
|
||||
@@ -601,71 +601,72 @@ func summaryLines() string {
|
||||
return "Error: Scan with --debug to view the details"
|
||||
}
|
||||
|
||||
indexFormat := ""
|
||||
if len(currentScanResult.AllCves()) < 10 {
|
||||
indexFormat = "[%1d]"
|
||||
} else if len(currentScanResult.AllCves()) < 100 {
|
||||
indexFormat = "[%2d]"
|
||||
} else {
|
||||
indexFormat = "[%3d]"
|
||||
}
|
||||
//TODO
|
||||
// indexFormat := ""
|
||||
// if len(currentScanResult.AllCves()) < 10 {
|
||||
// indexFormat = "[%1d]"
|
||||
// } else if len(currentScanResult.AllCves()) < 100 {
|
||||
// indexFormat = "[%2d]"
|
||||
// } else {
|
||||
// indexFormat = "[%3d]"
|
||||
// }
|
||||
|
||||
for i, d := range currentScanResult.AllCves() {
|
||||
var cols []string
|
||||
//TODO
|
||||
var summary string
|
||||
if cont, found := d.Get(models.NVD); found {
|
||||
summary = cont.Summary
|
||||
}
|
||||
var cvssScore string
|
||||
if d.CvssV2Score() <= 0 {
|
||||
cvssScore = "| ?"
|
||||
} else {
|
||||
cvssScore = fmt.Sprintf("| %4.1f", d.CvssV2Score())
|
||||
}
|
||||
cols = []string{
|
||||
fmt.Sprintf(indexFormat, i+1),
|
||||
d.VulnInfo.CveID,
|
||||
cvssScore,
|
||||
fmt.Sprintf("| %3d |", d.VulnInfo.Confidence.Score),
|
||||
summary,
|
||||
}
|
||||
// if config.Conf.Lang == "ja" && 0 < d.CveDetail.Jvn.CvssScore() {
|
||||
// summary := d.CveDetail.Jvn.CveTitle()
|
||||
// cols = []string{
|
||||
// fmt.Sprintf(indexFormat, i+1),
|
||||
// d.CveDetail.CveID,
|
||||
// fmt.Sprintf("| %4.1f",
|
||||
// d.CveDetail.CvssScore(config.Conf.Lang)),
|
||||
// fmt.Sprintf("| %3d |", d.VulnInfo.Confidence.Score),
|
||||
// summary,
|
||||
// }
|
||||
// } else {
|
||||
// summary := d.CveDetail.Nvd.CveSummary()
|
||||
// for i, d := range currentScanResult.AllCves() {
|
||||
// var cols []string
|
||||
// //TODO
|
||||
// var summary string
|
||||
// if cont, found := d.Get(models.NVD); found {
|
||||
// summary = cont.Summary
|
||||
// }
|
||||
// var cvssScore string
|
||||
// if d.CvssV2Score() <= 0 {
|
||||
// cvssScore = "| ?"
|
||||
// } else {
|
||||
// cvssScore = fmt.Sprintf("| %4.1f", d.CvssV2Score())
|
||||
// }
|
||||
// cols = []string{
|
||||
// fmt.Sprintf(indexFormat, i+1),
|
||||
// d.VulnInfo.CveID,
|
||||
// cvssScore,
|
||||
// fmt.Sprintf("| %3d |", d.VulnInfo.Confidence.Score),
|
||||
// summary,
|
||||
// }
|
||||
// // if config.Conf.Lang == "ja" && 0 < d.CveDetail.Jvn.CvssScore() {
|
||||
// // summary := d.CveDetail.Jvn.CveTitle()
|
||||
// // cols = []string{
|
||||
// // fmt.Sprintf(indexFormat, i+1),
|
||||
// // d.CveDetail.CveID,
|
||||
// // fmt.Sprintf("| %4.1f",
|
||||
// // d.CveDetail.CvssScore(config.Conf.Lang)),
|
||||
// // fmt.Sprintf("| %3d |", d.VulnInfo.Confidence.Score),
|
||||
// // summary,
|
||||
// // }
|
||||
// // } else {
|
||||
// // summary := d.CveDetail.Nvd.CveSummary()
|
||||
|
||||
// var cvssScore string
|
||||
// if d.CveDetail.CvssScore("en") <= 0 {
|
||||
// cvssScore = "| ?"
|
||||
// } else {
|
||||
// cvssScore = fmt.Sprintf("| %4.1f",
|
||||
// d.CveDetail.CvssScore(config.Conf.Lang))
|
||||
// }
|
||||
// // var cvssScore string
|
||||
// // if d.CveDetail.CvssScore("en") <= 0 {
|
||||
// // cvssScore = "| ?"
|
||||
// // } else {
|
||||
// // cvssScore = fmt.Sprintf("| %4.1f",
|
||||
// // d.CveDetail.CvssScore(config.Conf.Lang))
|
||||
// // }
|
||||
|
||||
// cols = []string{
|
||||
// fmt.Sprintf(indexFormat, i+1),
|
||||
// d.CveDetail.CveID,
|
||||
// cvssScore,
|
||||
// fmt.Sprintf("| %3d |", d.VulnInfo.Confidence.Score),
|
||||
// summary,
|
||||
// }
|
||||
// }
|
||||
// // cols = []string{
|
||||
// // fmt.Sprintf(indexFormat, i+1),
|
||||
// // d.CveDetail.CveID,
|
||||
// // cvssScore,
|
||||
// // fmt.Sprintf("| %3d |", d.VulnInfo.Confidence.Score),
|
||||
// // summary,
|
||||
// // }
|
||||
// // }
|
||||
|
||||
icols := make([]interface{}, len(cols))
|
||||
for j := range cols {
|
||||
icols[j] = cols[j]
|
||||
}
|
||||
stable.AddRow(icols...)
|
||||
}
|
||||
// icols := make([]interface{}, len(cols))
|
||||
// for j := range cols {
|
||||
// icols[j] = cols[j]
|
||||
// }
|
||||
// stable.AddRow(icols...)
|
||||
// }
|
||||
return fmt.Sprintf("%s", stable)
|
||||
}
|
||||
|
||||
@@ -712,19 +713,21 @@ func setChangelogLayout(g *gocui.Gui) error {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
}
|
||||
if len(currentScanResult.Errors) != 0 || len(currentScanResult.AllCves()) == 0 {
|
||||
return nil
|
||||
}
|
||||
//TODO
|
||||
// if len(currentScanResult.Errors) != 0 || len(currentScanResult.AllCves()) == 0 {
|
||||
// return nil
|
||||
// }
|
||||
|
||||
lines := []string{}
|
||||
cveInfo := currentScanResult.AllCves()[currentCveInfo]
|
||||
for _, pack := range cveInfo.Packages {
|
||||
for _, p := range currentScanResult.Packages {
|
||||
if pack.Name == p.Name {
|
||||
lines = append(lines, formatOneChangelog(p), "\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
// cveInfo := currentScanResult.AllCves()[currentCveInfo]
|
||||
// for _, pack := range cveInfo.Packages {
|
||||
// for _, p := range currentScanResult.Packages {
|
||||
// if pack.Name == p.Name {
|
||||
// lines = append(lines, formatOneChangelog(p), "\n")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
text := strings.Join(lines, "\n")
|
||||
fmt.Fprint(v, text)
|
||||
v.Editable = false
|
||||
@@ -756,20 +759,20 @@ func detailLines() (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
if len(currentScanResult.AllCves()) == 0 {
|
||||
return "No vulnerable packages", nil
|
||||
}
|
||||
//TODO
|
||||
// if len(currentScanResult.AllCves()) == 0 {
|
||||
// return "No vulnerable packages", nil
|
||||
// }
|
||||
// cveInfo := currentScanResult.AllCves()[currentCveInfo]
|
||||
// cveID := cveInfo.VulnInfo.CveID
|
||||
|
||||
cveInfo := currentScanResult.AllCves()[currentCveInfo]
|
||||
cveID := cveInfo.VulnInfo.CveID
|
||||
// tmpl, err := template.New("detail").Parse(detailTemplate())
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
|
||||
tmpl, err := template.New("detail").Parse(detailTemplate())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var cvssSeverity, cvssVector, summary string
|
||||
var refs []cve.Reference
|
||||
// var cvssSeverity, cvssVector, summary string
|
||||
// var refs []cve.Reference
|
||||
switch {
|
||||
//TODO
|
||||
// case config.Conf.Lang == "ja" &&
|
||||
@@ -780,67 +783,67 @@ func detailLines() (string, error) {
|
||||
// summary = fmt.Sprintf("%s\n%s", jvn.CveTitle(), jvn.CveSummary())
|
||||
// refs = jvn.VulnSiteReferences()
|
||||
default:
|
||||
var nvd *models.CveContent
|
||||
if cont, found := cveInfo.Get(models.NVD); found {
|
||||
nvd = cont
|
||||
}
|
||||
// var nvd *models.CveContent
|
||||
//TODO
|
||||
// if cont, found := cveInfo.Get(models.NVD); found {
|
||||
// nvd = cont
|
||||
// }
|
||||
// cvssSeverity = nvd.CvssSeverity()
|
||||
// cvssVector = nvd.CvssVector()
|
||||
summary = nvd.Summary
|
||||
// summary = nvd.Summary
|
||||
// refs = nvd.VulnSiteReferences()
|
||||
}
|
||||
|
||||
//TODO
|
||||
// cweURL := cweURL(cveInfo.CveDetail.CweID())
|
||||
|
||||
links := []string{
|
||||
fmt.Sprintf("[NVD]( %s )", fmt.Sprintf("%s/%s", nvdBaseURL, cveID)),
|
||||
fmt.Sprintf("[MITRE]( %s )", fmt.Sprintf("%s%s", mitreBaseURL, cveID)),
|
||||
fmt.Sprintf("[CveDetais]( %s )", fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID)),
|
||||
fmt.Sprintf("[CVSSv2 Calc]( %s )", fmt.Sprintf(cvssV2CalcBaseURL, cveID)),
|
||||
fmt.Sprintf("[CVSSv3 Calc]( %s )", fmt.Sprintf(cvssV3CalcBaseURL, cveID)),
|
||||
}
|
||||
dlinks := distroLinks(cveInfo, currentScanResult.Family)
|
||||
for _, link := range dlinks {
|
||||
links = append(links, fmt.Sprintf("[%s]( %s )", link.title, link.url))
|
||||
}
|
||||
// links := []string{
|
||||
// fmt.Sprintf("[NVD]( %s )", fmt.Sprintf("%s/%s", nvdBaseURL, cveID)),
|
||||
// fmt.Sprintf("[MITRE]( %s )", fmt.Sprintf("%s%s", mitreBaseURL, cveID)),
|
||||
// fmt.Sprintf("[CveDetais]( %s )", fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID)),
|
||||
// fmt.Sprintf("[CVSSv2 Calc]( %s )", fmt.Sprintf(cvssV2CalcBaseURL, cveID)),
|
||||
// fmt.Sprintf("[CVSSv3 Calc]( %s )", fmt.Sprintf(cvssV3CalcBaseURL, cveID)),
|
||||
// }
|
||||
// dlinks := distroLinks(cveInfo, currentScanResult.Family)
|
||||
// for _, link := range dlinks {
|
||||
// links = append(links, fmt.Sprintf("[%s]( %s )", link.title, link.url))
|
||||
// }
|
||||
|
||||
//TODO
|
||||
var cvssScore string
|
||||
if cveInfo.CvssV2Score() == -1 {
|
||||
cvssScore = "?"
|
||||
// } else {
|
||||
// cvssScore = fmt.Sprintf("%4.1f", cveInfo.CveDetail.CvssScore(config.Conf.Lang))
|
||||
}
|
||||
// var cvssScore string
|
||||
// if cveInfo.CvssV2Score() == -1 {
|
||||
// cvssScore = "?"
|
||||
// // } else {
|
||||
// // cvssScore = fmt.Sprintf("%4.1f", cveInfo.CveDetail.CvssScore(config.Conf.Lang))
|
||||
// }
|
||||
|
||||
packages := []string{}
|
||||
for _, pack := range cveInfo.Packages {
|
||||
packages = append(packages,
|
||||
fmt.Sprintf(
|
||||
"%s -> %s",
|
||||
pack.FormatCurrentVer(),
|
||||
pack.FormatNewVer()))
|
||||
}
|
||||
// packages := []string{}
|
||||
// for _, pack := range cveInfo.Packages {
|
||||
// packages = append(packages,
|
||||
// fmt.Sprintf(
|
||||
// "%s -> %s",
|
||||
// pack.FormatCurrentVer(),
|
||||
// pack.FormatNewVer()))
|
||||
// }
|
||||
|
||||
data := dataForTmpl{
|
||||
CveID: cveID,
|
||||
CvssScore: cvssScore,
|
||||
CvssSeverity: cvssSeverity,
|
||||
CvssVector: cvssVector,
|
||||
Summary: summary,
|
||||
Confidence: cveInfo.VulnInfo.Confidence,
|
||||
//TODO
|
||||
// CweURL: cweURL,
|
||||
VulnSiteLinks: links,
|
||||
References: refs,
|
||||
Packages: packages,
|
||||
CpeNames: cveInfo.CpeNames,
|
||||
}
|
||||
// data := dataForTmpl{
|
||||
// CveID: cveID,
|
||||
// CvssScore: cvssScore,
|
||||
// CvssSeverity: cvssSeverity,
|
||||
// CvssVector: cvssVector,
|
||||
// Summary: summary,
|
||||
// Confidence: cveInfo.VulnInfo.Confidence,
|
||||
// //TODO
|
||||
// // CweURL: cweURL,
|
||||
// VulnSiteLinks: links,
|
||||
// References: refs,
|
||||
// Packages: packages,
|
||||
// CpeNames: cveInfo.CpeNames,
|
||||
// }
|
||||
|
||||
buf := bytes.NewBuffer(nil) // create empty buffer
|
||||
if err := tmpl.Execute(buf, data); err != nil {
|
||||
return "", err
|
||||
}
|
||||
// if err := tmpl.Execute(buf, data); err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
|
||||
return string(buf.Bytes()), nil
|
||||
}
|
||||
|
||||
547
report/util.go
547
report/util.go
@@ -22,7 +22,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/future-architect/vuls/config"
|
||||
"github.com/future-architect/vuls/models"
|
||||
"github.com/gosuri/uitable"
|
||||
)
|
||||
@@ -84,10 +83,11 @@ func formatShortPlainText(r models.ScanResult) string {
|
||||
stable.MaxColWidth = maxColWidth
|
||||
stable.Wrap = true
|
||||
|
||||
cves := r.KnownCves
|
||||
if !config.Conf.IgnoreUnscoredCves {
|
||||
cves = append(cves, r.UnknownCves...)
|
||||
}
|
||||
//TODO
|
||||
// cves := r.KnownCves
|
||||
// if !config.Conf.IgnoreUnscoredCves {
|
||||
// cves = append(cves, r.UnknownCves...)
|
||||
// }
|
||||
|
||||
var buf bytes.Buffer
|
||||
for i := 0; i < len(r.ServerInfo()); i++ {
|
||||
@@ -106,83 +106,84 @@ func formatShortPlainText(r models.ScanResult) string {
|
||||
header, r.Errors)
|
||||
}
|
||||
|
||||
if len(cves) == 0 {
|
||||
return fmt.Sprintf(`
|
||||
%s
|
||||
No CVE-IDs are found in updatable packages.
|
||||
%s
|
||||
`, header, r.Packages.FormatUpdatablePacksSummary())
|
||||
}
|
||||
//TODO
|
||||
// if len(cves) == 0 {
|
||||
// return fmt.Sprintf(`
|
||||
// %s
|
||||
// No CVE-IDs are found in updatable packages.
|
||||
// %s
|
||||
// `, header, r.Packages.FormatUpdatablePacksSummary())
|
||||
// }
|
||||
|
||||
for _, d := range cves {
|
||||
var packsVer string
|
||||
for _, p := range d.Packages {
|
||||
packsVer += fmt.Sprintf(
|
||||
"%s -> %s\n", p.FormatCurrentVer(), p.FormatNewVer())
|
||||
}
|
||||
for _, n := range d.CpeNames {
|
||||
packsVer += n
|
||||
}
|
||||
// for _, d := range cves {
|
||||
// var packsVer string
|
||||
// for _, p := range d.Packages {
|
||||
// packsVer += fmt.Sprintf(
|
||||
// "%s -> %s\n", p.FormatCurrentVer(), p.FormatNewVer())
|
||||
// }
|
||||
// for _, n := range d.CpeNames {
|
||||
// packsVer += n
|
||||
// }
|
||||
|
||||
var scols []string
|
||||
switch {
|
||||
// case config.Conf.Lang == "ja" &&
|
||||
//TODO
|
||||
// 0 < d.CveDetail.Jvn.CvssScore():
|
||||
// summary := fmt.Sprintf("%s\n%s\n%s\n%sConfidence: %v",
|
||||
// d.CveDetail.Jvn.CveTitle(),
|
||||
// d.CveDetail.Jvn.Link(),
|
||||
// distroLinks(d, r.Family)[0].url,
|
||||
// packsVer,
|
||||
// d.VulnInfo.Confidence,
|
||||
// )
|
||||
// scols = []string{
|
||||
// d.CveDetail.CveID,
|
||||
// fmt.Sprintf("%-4.1f (%s)",
|
||||
// d.CveDetail.CvssScore(config.Conf.Lang),
|
||||
// d.CveDetail.Jvn.CvssSeverity(),
|
||||
// ),
|
||||
// summary,
|
||||
// }
|
||||
// var scols []string
|
||||
// switch {
|
||||
// // case config.Conf.Lang == "ja" &&
|
||||
// //TODO
|
||||
// // 0 < d.CveDetail.Jvn.CvssScore():
|
||||
// // summary := fmt.Sprintf("%s\n%s\n%s\n%sConfidence: %v",
|
||||
// // d.CveDetail.Jvn.CveTitle(),
|
||||
// // d.CveDetail.Jvn.Link(),
|
||||
// // distroLinks(d, r.Family)[0].url,
|
||||
// // packsVer,
|
||||
// // d.VulnInfo.Confidence,
|
||||
// // )
|
||||
// // scols = []string{
|
||||
// // d.CveDetail.CveID,
|
||||
// // fmt.Sprintf("%-4.1f (%s)",
|
||||
// // d.CveDetail.CvssScore(config.Conf.Lang),
|
||||
// // d.CveDetail.Jvn.CvssSeverity(),
|
||||
// // ),
|
||||
// // summary,
|
||||
// // }
|
||||
|
||||
case 0 < d.CvssV2Score():
|
||||
var nvd *models.CveContent
|
||||
if cont, found := d.Get(models.NVD); found {
|
||||
nvd = cont
|
||||
}
|
||||
summary := fmt.Sprintf("%s\n%s/%s\n%s\n%sConfidence: %v",
|
||||
nvd.Summary,
|
||||
cveDetailsBaseURL,
|
||||
d.VulnInfo.CveID,
|
||||
distroLinks(d, r.Family)[0].url,
|
||||
packsVer,
|
||||
d.VulnInfo.Confidence,
|
||||
)
|
||||
scols = []string{
|
||||
d.VulnInfo.CveID,
|
||||
fmt.Sprintf("%-4.1f (%s)",
|
||||
d.CvssV2Score(),
|
||||
"TODO",
|
||||
),
|
||||
summary,
|
||||
}
|
||||
default:
|
||||
summary := fmt.Sprintf("%s\n%sConfidence: %v",
|
||||
distroLinks(d, r.Family)[0].url, packsVer, d.VulnInfo.Confidence)
|
||||
scols = []string{
|
||||
d.VulnInfo.CveID,
|
||||
"?",
|
||||
summary,
|
||||
}
|
||||
}
|
||||
// case 0 < d.CvssV2Score():
|
||||
// var nvd *models.CveContent
|
||||
// if cont, found := d.Get(models.NVD); found {
|
||||
// nvd = cont
|
||||
// }
|
||||
// summary := fmt.Sprintf("%s\n%s/%s\n%s\n%sConfidence: %v",
|
||||
// nvd.Summary,
|
||||
// cveDetailsBaseURL,
|
||||
// d.VulnInfo.CveID,
|
||||
// distroLinks(d, r.Family)[0].url,
|
||||
// packsVer,
|
||||
// d.VulnInfo.Confidence,
|
||||
// )
|
||||
// scols = []string{
|
||||
// d.VulnInfo.CveID,
|
||||
// fmt.Sprintf("%-4.1f (%s)",
|
||||
// d.CvssV2Score(),
|
||||
// "TODO",
|
||||
// ),
|
||||
// summary,
|
||||
// }
|
||||
// default:
|
||||
// summary := fmt.Sprintf("%s\n%sConfidence: %v",
|
||||
// distroLinks(d, r.Family)[0].url, packsVer, d.VulnInfo.Confidence)
|
||||
// scols = []string{
|
||||
// d.VulnInfo.CveID,
|
||||
// "?",
|
||||
// summary,
|
||||
// }
|
||||
// }
|
||||
|
||||
cols := make([]interface{}, len(scols))
|
||||
for i := range cols {
|
||||
cols[i] = scols[i]
|
||||
}
|
||||
stable.AddRow(cols...)
|
||||
stable.AddRow("")
|
||||
}
|
||||
// cols := make([]interface{}, len(scols))
|
||||
// for i := range cols {
|
||||
// cols[i] = scols[i]
|
||||
// }
|
||||
// stable.AddRow(cols...)
|
||||
// stable.AddRow("")
|
||||
// }
|
||||
return fmt.Sprintf("%s\n%s\n", header, stable)
|
||||
}
|
||||
|
||||
@@ -206,32 +207,34 @@ func formatFullPlainText(r models.ScanResult) string {
|
||||
header, r.Errors)
|
||||
}
|
||||
|
||||
if len(r.KnownCves) == 0 && len(r.UnknownCves) == 0 {
|
||||
return fmt.Sprintf(`
|
||||
%s
|
||||
No CVE-IDs are found in updatable packages.
|
||||
%s
|
||||
`, header, r.Packages.FormatUpdatablePacksSummary())
|
||||
}
|
||||
//TODO
|
||||
// if len(r.KnownCves) == 0 && len(r.UnknownCves) == 0 {
|
||||
// return fmt.Sprintf(`
|
||||
// %s
|
||||
// No CVE-IDs are found in updatable packages.
|
||||
// %s
|
||||
// `, header, r.Packages.FormatUpdatablePacksSummary())
|
||||
// }
|
||||
|
||||
scoredReport, unscoredReport := []string{}, []string{}
|
||||
scoredReport, unscoredReport = formatPlainTextDetails(r, r.Family)
|
||||
// scoredReport, unscoredReport := []string{}, []string{}
|
||||
// scoredReport, unscoredReport = formatPlainTextDetails(r, r.Family)
|
||||
|
||||
unscored := ""
|
||||
if !config.Conf.IgnoreUnscoredCves {
|
||||
unscored = strings.Join(unscoredReport, "\n\n")
|
||||
}
|
||||
// unscored := ""
|
||||
// if !config.Conf.IgnoreUnscoredCves {
|
||||
// unscored = strings.Join(unscoredReport, "\n\n")
|
||||
// }
|
||||
|
||||
scored := strings.Join(scoredReport, "\n\n")
|
||||
detail := fmt.Sprintf(`
|
||||
%s
|
||||
// scored := strings.Join(scoredReport, "\n\n")
|
||||
// detail := fmt.Sprintf(`
|
||||
// %s
|
||||
|
||||
%s
|
||||
`,
|
||||
scored,
|
||||
unscored,
|
||||
)
|
||||
return fmt.Sprintf("%s\n%s\n%s", header, detail, formatChangelogs(r))
|
||||
// %s
|
||||
// `,
|
||||
// scored,
|
||||
// unscored,
|
||||
// )
|
||||
// return fmt.Sprintf("%s\n%s\n%s", header, detail, formatChangelogs(r))
|
||||
return ""
|
||||
}
|
||||
|
||||
//TODO
|
||||
@@ -266,116 +269,116 @@ func formatPlainTextDetails(r models.ScanResult, osFamily string) (scoredReport,
|
||||
return
|
||||
}
|
||||
|
||||
func formatPlainTextUnknownCve(cveInfo models.CveInfo, osFamily string) string {
|
||||
cveID := cveInfo.VulnInfo.CveID
|
||||
dtable := uitable.New()
|
||||
dtable.MaxColWidth = maxColWidth
|
||||
dtable.Wrap = true
|
||||
dtable.AddRow(cveID)
|
||||
dtable.AddRow("-------------")
|
||||
dtable.AddRow("Score", "?")
|
||||
dtable.AddRow("NVD", fmt.Sprintf("%s/%s", nvdBaseURL, cveID))
|
||||
dlinks := distroLinks(cveInfo, osFamily)
|
||||
for _, link := range dlinks {
|
||||
dtable.AddRow(link.title, link.url)
|
||||
}
|
||||
dtable.AddRow("CVE Details", fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID))
|
||||
dtable = addPackageInfos(dtable, cveInfo.Packages)
|
||||
dtable = addCpeNames(dtable, cveInfo.CpeNames)
|
||||
dtable.AddRow("Confidence", cveInfo.VulnInfo.Confidence)
|
||||
// func formatPlainTextUnknownCve(cveInfo models.CveInfo, osFamily string) string {
|
||||
// cveID := cveInfo.VulnInfo.CveID
|
||||
// dtable := uitable.New()
|
||||
// dtable.MaxColWidth = maxColWidth
|
||||
// dtable.Wrap = true
|
||||
// dtable.AddRow(cveID)
|
||||
// dtable.AddRow("-------------")
|
||||
// dtable.AddRow("Score", "?")
|
||||
// dtable.AddRow("NVD", fmt.Sprintf("%s/%s", nvdBaseURL, cveID))
|
||||
// dlinks := distroLinks(cveInfo, osFamily)
|
||||
// for _, link := range dlinks {
|
||||
// dtable.AddRow(link.title, link.url)
|
||||
// }
|
||||
// dtable.AddRow("CVE Details", fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID))
|
||||
// dtable = addPackageInfos(dtable, cveInfo.Packages)
|
||||
// dtable = addCpeNames(dtable, cveInfo.CpeNames)
|
||||
// dtable.AddRow("Confidence", cveInfo.VulnInfo.Confidence)
|
||||
|
||||
return fmt.Sprintf("%s", dtable)
|
||||
}
|
||||
// return fmt.Sprintf("%s", dtable)
|
||||
// }
|
||||
|
||||
//TODO
|
||||
func formatPlainTextDetailsLangJa(cveInfo models.CveInfo, osFamily string) string {
|
||||
return "TODO"
|
||||
// cveDetail := cveInfo.CveDetail
|
||||
// cveID := cveDetail.CveID
|
||||
// jvn := cveDetail.Jvn
|
||||
// func formatPlainTextDetailsLangJa(cveInfo models.CveInfo, osFamily string) string {
|
||||
// return "TODO"
|
||||
// cveDetail := cveInfo.CveDetail
|
||||
// cveID := cveDetail.CveID
|
||||
// jvn := cveDetail.Jvn
|
||||
|
||||
// dtable := uitable.New()
|
||||
// dtable.MaxColWidth = maxColWidth
|
||||
// dtable.Wrap = true
|
||||
// dtable.AddRow(cveID)
|
||||
// dtable.AddRow("-------------")
|
||||
// if score := cveDetail.Jvn.CvssScore(); 0 < score {
|
||||
// dtable.AddRow("Score",
|
||||
// fmt.Sprintf("%4.1f (%s)",
|
||||
// cveDetail.Jvn.CvssScore(),
|
||||
// jvn.CvssSeverity(),
|
||||
// ))
|
||||
// } else {
|
||||
// dtable.AddRow("Score", "?")
|
||||
// }
|
||||
// dtable.AddRow("Vector", jvn.CvssVector())
|
||||
// dtable.AddRow("Title", jvn.CveTitle())
|
||||
// dtable.AddRow("Description", jvn.CveSummary())
|
||||
// dtable.AddRow(cveDetail.CweID(), cweURL(cveDetail.CweID()))
|
||||
// dtable.AddRow(cveDetail.CweID()+"(JVN)", cweJvnURL(cveDetail.CweID()))
|
||||
// dtable := uitable.New()
|
||||
// dtable.MaxColWidth = maxColWidth
|
||||
// dtable.Wrap = true
|
||||
// dtable.AddRow(cveID)
|
||||
// dtable.AddRow("-------------")
|
||||
// if score := cveDetail.Jvn.CvssScore(); 0 < score {
|
||||
// dtable.AddRow("Score",
|
||||
// fmt.Sprintf("%4.1f (%s)",
|
||||
// cveDetail.Jvn.CvssScore(),
|
||||
// jvn.CvssSeverity(),
|
||||
// ))
|
||||
// } else {
|
||||
// dtable.AddRow("Score", "?")
|
||||
// }
|
||||
// dtable.AddRow("Vector", jvn.CvssVector())
|
||||
// dtable.AddRow("Title", jvn.CveTitle())
|
||||
// dtable.AddRow("Description", jvn.CveSummary())
|
||||
// dtable.AddRow(cveDetail.CweID(), cweURL(cveDetail.CweID()))
|
||||
// dtable.AddRow(cveDetail.CweID()+"(JVN)", cweJvnURL(cveDetail.CweID()))
|
||||
|
||||
// dtable.AddRow("JVN", jvn.Link())
|
||||
// dtable.AddRow("NVD", fmt.Sprintf("%s/%s", nvdBaseURL, cveID))
|
||||
// dtable.AddRow("MITRE", fmt.Sprintf("%s%s", mitreBaseURL, cveID))
|
||||
// dtable.AddRow("CVE Details", fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID))
|
||||
// dtable.AddRow("CVSSv2 Clac", fmt.Sprintf(cvssV2CalcBaseURL, cveID))
|
||||
// dtable.AddRow("CVSSv3 Clac", fmt.Sprintf(cvssV3CalcBaseURL, cveID))
|
||||
// dtable.AddRow("JVN", jvn.Link())
|
||||
// dtable.AddRow("NVD", fmt.Sprintf("%s/%s", nvdBaseURL, cveID))
|
||||
// dtable.AddRow("MITRE", fmt.Sprintf("%s%s", mitreBaseURL, cveID))
|
||||
// dtable.AddRow("CVE Details", fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID))
|
||||
// dtable.AddRow("CVSSv2 Clac", fmt.Sprintf(cvssV2CalcBaseURL, cveID))
|
||||
// dtable.AddRow("CVSSv3 Clac", fmt.Sprintf(cvssV3CalcBaseURL, cveID))
|
||||
|
||||
// dlinks := distroLinks(cveInfo, osFamily)
|
||||
// for _, link := range dlinks {
|
||||
// dtable.AddRow(link.title, link.url)
|
||||
// }
|
||||
// dlinks := distroLinks(cveInfo, osFamily)
|
||||
// for _, link := range dlinks {
|
||||
// dtable.AddRow(link.title, link.url)
|
||||
// }
|
||||
|
||||
// dtable = addPackageInfos(dtable, cveInfo.Packages)
|
||||
// dtable = addCpeNames(dtable, cveInfo.CpeNames)
|
||||
// dtable.AddRow("Confidence", cveInfo.VulnInfo.Confidence)
|
||||
// dtable = addPackageInfos(dtable, cveInfo.Packages)
|
||||
// dtable = addCpeNames(dtable, cveInfo.CpeNames)
|
||||
// dtable.AddRow("Confidence", cveInfo.VulnInfo.Confidence)
|
||||
|
||||
// return fmt.Sprintf("%s", dtable)
|
||||
}
|
||||
// return fmt.Sprintf("%s", dtable)
|
||||
// }
|
||||
|
||||
//TODO
|
||||
func formatPlainTextDetailsLangEn(d models.CveInfo, osFamily string) string {
|
||||
return ""
|
||||
// cveDetail := d.CveDetail
|
||||
// cveID := cveDetail.CveID
|
||||
// nvd := cveDetail.Nvd
|
||||
// func formatPlainTextDetailsLangEn(d models.CveInfo, osFamily string) string {
|
||||
// return ""
|
||||
// cveDetail := d.CveDetail
|
||||
// cveID := cveDetail.CveID
|
||||
// nvd := cveDetail.Nvd
|
||||
|
||||
// dtable := uitable.New()
|
||||
// dtable.MaxColWidth = maxColWidth
|
||||
// dtable.Wrap = true
|
||||
// dtable.AddRow(cveID)
|
||||
// dtable.AddRow("-------------")
|
||||
// dtable := uitable.New()
|
||||
// dtable.MaxColWidth = maxColWidth
|
||||
// dtable.Wrap = true
|
||||
// dtable.AddRow(cveID)
|
||||
// dtable.AddRow("-------------")
|
||||
|
||||
// if score := cveDetail.Nvd.CvssScore(); 0 < score {
|
||||
// dtable.AddRow("Score",
|
||||
// fmt.Sprintf("%4.1f (%s)",
|
||||
// cveDetail.Nvd.CvssScore(),
|
||||
// nvd.CvssSeverity(),
|
||||
// ))
|
||||
// } else {
|
||||
// dtable.AddRow("Score", "?")
|
||||
// }
|
||||
// if score := cveDetail.Nvd.CvssScore(); 0 < score {
|
||||
// dtable.AddRow("Score",
|
||||
// fmt.Sprintf("%4.1f (%s)",
|
||||
// cveDetail.Nvd.CvssScore(),
|
||||
// nvd.CvssSeverity(),
|
||||
// ))
|
||||
// } else {
|
||||
// dtable.AddRow("Score", "?")
|
||||
// }
|
||||
|
||||
// dtable.AddRow("Vector", nvd.CvssVector())
|
||||
// dtable.AddRow("Summary", nvd.CveSummary())
|
||||
// dtable.AddRow("CWE", cweURL(cveDetail.CweID()))
|
||||
// dtable.AddRow("Vector", nvd.CvssVector())
|
||||
// dtable.AddRow("Summary", nvd.CveSummary())
|
||||
// dtable.AddRow("CWE", cweURL(cveDetail.CweID()))
|
||||
|
||||
// dtable.AddRow("NVD", fmt.Sprintf("%s/%s", nvdBaseURL, cveID))
|
||||
// dtable.AddRow("MITRE", fmt.Sprintf("%s%s", mitreBaseURL, cveID))
|
||||
// dtable.AddRow("CVE Details", fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID))
|
||||
// dtable.AddRow("CVSSv2 Clac", fmt.Sprintf(cvssV2CalcBaseURL, cveID))
|
||||
// dtable.AddRow("CVSSv3 Clac", fmt.Sprintf(cvssV3CalcBaseURL, cveID))
|
||||
// dtable.AddRow("NVD", fmt.Sprintf("%s/%s", nvdBaseURL, cveID))
|
||||
// dtable.AddRow("MITRE", fmt.Sprintf("%s%s", mitreBaseURL, cveID))
|
||||
// dtable.AddRow("CVE Details", fmt.Sprintf("%s/%s", cveDetailsBaseURL, cveID))
|
||||
// dtable.AddRow("CVSSv2 Clac", fmt.Sprintf(cvssV2CalcBaseURL, cveID))
|
||||
// dtable.AddRow("CVSSv3 Clac", fmt.Sprintf(cvssV3CalcBaseURL, cveID))
|
||||
|
||||
// links := distroLinks(d, osFamily)
|
||||
// for _, link := range links {
|
||||
// dtable.AddRow(link.title, link.url)
|
||||
// }
|
||||
// dtable = addPackageInfos(dtable, d.Packages)
|
||||
// dtable = addCpeNames(dtable, d.CpeNames)
|
||||
// dtable.AddRow("Confidence", d.VulnInfo.Confidence)
|
||||
// links := distroLinks(d, osFamily)
|
||||
// for _, link := range links {
|
||||
// dtable.AddRow(link.title, link.url)
|
||||
// }
|
||||
// dtable = addPackageInfos(dtable, d.Packages)
|
||||
// dtable = addCpeNames(dtable, d.CpeNames)
|
||||
// dtable.AddRow("Confidence", d.VulnInfo.Confidence)
|
||||
|
||||
// return fmt.Sprintf("%s\n", dtable)
|
||||
}
|
||||
// return fmt.Sprintf("%s\n", dtable)
|
||||
// }
|
||||
|
||||
type distroLink struct {
|
||||
title string
|
||||
@@ -383,84 +386,84 @@ type distroLink struct {
|
||||
}
|
||||
|
||||
// distroLinks add Vendor URL of the CVE to table
|
||||
func distroLinks(cveInfo models.CveInfo, osFamily string) []distroLink {
|
||||
cveID := cveInfo.VulnInfo.CveID
|
||||
switch osFamily {
|
||||
case "rhel", "centos":
|
||||
links := []distroLink{
|
||||
{
|
||||
"RHEL-CVE",
|
||||
fmt.Sprintf("%s/%s", redhatSecurityBaseURL, cveID),
|
||||
},
|
||||
}
|
||||
for _, advisory := range cveInfo.DistroAdvisories {
|
||||
aidURL := strings.Replace(advisory.AdvisoryID, ":", "-", -1)
|
||||
links = append(links, distroLink{
|
||||
// "RHEL-errata",
|
||||
advisory.AdvisoryID,
|
||||
fmt.Sprintf(redhatRHSABaseBaseURL, aidURL),
|
||||
})
|
||||
}
|
||||
return links
|
||||
case "oraclelinux":
|
||||
links := []distroLink{
|
||||
{
|
||||
"Oracle-CVE",
|
||||
fmt.Sprintf(oracleSecurityBaseURL, cveID),
|
||||
},
|
||||
}
|
||||
for _, advisory := range cveInfo.DistroAdvisories {
|
||||
links = append(links, distroLink{
|
||||
// "Oracle-ELSA"
|
||||
advisory.AdvisoryID,
|
||||
fmt.Sprintf(oracleELSABaseBaseURL, advisory.AdvisoryID),
|
||||
})
|
||||
}
|
||||
return links
|
||||
case "amazon":
|
||||
links := []distroLink{
|
||||
{
|
||||
"RHEL-CVE",
|
||||
fmt.Sprintf("%s/%s", redhatSecurityBaseURL, cveID),
|
||||
},
|
||||
}
|
||||
for _, advisory := range cveInfo.DistroAdvisories {
|
||||
links = append(links, distroLink{
|
||||
// "Amazon-ALAS",
|
||||
advisory.AdvisoryID,
|
||||
fmt.Sprintf(amazonSecurityBaseURL, advisory.AdvisoryID),
|
||||
})
|
||||
}
|
||||
return links
|
||||
case "ubuntu":
|
||||
return []distroLink{
|
||||
{
|
||||
"Ubuntu-CVE",
|
||||
fmt.Sprintf("%s/%s", ubuntuSecurityBaseURL, cveID),
|
||||
},
|
||||
//TODO Ubuntu USN
|
||||
}
|
||||
case "debian":
|
||||
return []distroLink{
|
||||
{
|
||||
"Debian-CVE",
|
||||
fmt.Sprintf("%s/%s", debianTrackerBaseURL, cveID),
|
||||
},
|
||||
// TODO Debian dsa
|
||||
}
|
||||
case "FreeBSD":
|
||||
links := []distroLink{}
|
||||
for _, advisory := range cveInfo.DistroAdvisories {
|
||||
links = append(links, distroLink{
|
||||
"FreeBSD-VuXML",
|
||||
fmt.Sprintf(freeBSDVuXMLBaseURL, advisory.AdvisoryID),
|
||||
})
|
||||
}
|
||||
return links
|
||||
default:
|
||||
return []distroLink{}
|
||||
}
|
||||
}
|
||||
// func distroLinks(cveInfo models.CveInfo, osFamily string) []distroLink {
|
||||
// cveID := cveInfo.VulnInfo.CveID
|
||||
// switch osFamily {
|
||||
// case "rhel", "centos":
|
||||
// links := []distroLink{
|
||||
// {
|
||||
// "RHEL-CVE",
|
||||
// fmt.Sprintf("%s/%s", redhatSecurityBaseURL, cveID),
|
||||
// },
|
||||
// }
|
||||
// for _, advisory := range cveInfo.DistroAdvisories {
|
||||
// aidURL := strings.Replace(advisory.AdvisoryID, ":", "-", -1)
|
||||
// links = append(links, distroLink{
|
||||
// // "RHEL-errata",
|
||||
// advisory.AdvisoryID,
|
||||
// fmt.Sprintf(redhatRHSABaseBaseURL, aidURL),
|
||||
// })
|
||||
// }
|
||||
// return links
|
||||
// case "oraclelinux":
|
||||
// links := []distroLink{
|
||||
// {
|
||||
// "Oracle-CVE",
|
||||
// fmt.Sprintf(oracleSecurityBaseURL, cveID),
|
||||
// },
|
||||
// }
|
||||
// for _, advisory := range cveInfo.DistroAdvisories {
|
||||
// links = append(links, distroLink{
|
||||
// // "Oracle-ELSA"
|
||||
// advisory.AdvisoryID,
|
||||
// fmt.Sprintf(oracleELSABaseBaseURL, advisory.AdvisoryID),
|
||||
// })
|
||||
// }
|
||||
// return links
|
||||
// case "amazon":
|
||||
// links := []distroLink{
|
||||
// {
|
||||
// "RHEL-CVE",
|
||||
// fmt.Sprintf("%s/%s", redhatSecurityBaseURL, cveID),
|
||||
// },
|
||||
// }
|
||||
// for _, advisory := range cveInfo.DistroAdvisories {
|
||||
// links = append(links, distroLink{
|
||||
// // "Amazon-ALAS",
|
||||
// advisory.AdvisoryID,
|
||||
// fmt.Sprintf(amazonSecurityBaseURL, advisory.AdvisoryID),
|
||||
// })
|
||||
// }
|
||||
// return links
|
||||
// case "ubuntu":
|
||||
// return []distroLink{
|
||||
// {
|
||||
// "Ubuntu-CVE",
|
||||
// fmt.Sprintf("%s/%s", ubuntuSecurityBaseURL, cveID),
|
||||
// },
|
||||
// //TODO Ubuntu USN
|
||||
// }
|
||||
// case "debian":
|
||||
// return []distroLink{
|
||||
// {
|
||||
// "Debian-CVE",
|
||||
// fmt.Sprintf("%s/%s", debianTrackerBaseURL, cveID),
|
||||
// },
|
||||
// // TODO Debian dsa
|
||||
// }
|
||||
// case "FreeBSD":
|
||||
// links := []distroLink{}
|
||||
// for _, advisory := range cveInfo.DistroAdvisories {
|
||||
// links = append(links, distroLink{
|
||||
// "FreeBSD-VuXML",
|
||||
// fmt.Sprintf(freeBSDVuXMLBaseURL, advisory.AdvisoryID),
|
||||
// })
|
||||
// }
|
||||
// return links
|
||||
// default:
|
||||
// return []distroLink{}
|
||||
// }
|
||||
// }
|
||||
|
||||
// addPackageInfos add package information related the CVE to table
|
||||
func addPackageInfos(table *uitable.Table, packs []models.PackageInfo) *uitable.Table {
|
||||
|
||||
Reference in New Issue
Block a user