mirror of https://gitee.com/openkylin/genmai.git
增加漏洞信息VulnInfo显示功能
This commit is contained in:
parent
6ad98b4bd9
commit
275101db89
|
@ -36,7 +36,7 @@ import (
|
|||
type FrameReport struct {
|
||||
reports []genmai.ReportBase
|
||||
curReport genmai.ReportBase
|
||||
vulnInfos []genmai.VulnInfoBase
|
||||
vulnInfos []genmai.VulnInfoCommon
|
||||
curVulnInfo int
|
||||
curDetailLimitY int
|
||||
}
|
||||
|
@ -45,21 +45,16 @@ var G_FrameReport FrameReport
|
|||
|
||||
// TODO: may be should remove this function
|
||||
func (fr *FrameReport)Setup() {
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportKernel())
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportKernel())
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportKernel())
|
||||
/* */
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportDBus())
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportDBus())
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportDBus())
|
||||
/* */
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportSystem())
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportSystem())
|
||||
//fr.curReport =
|
||||
/* */
|
||||
fr.vulnInfos = append(fr.vulnInfos, genmai.GetTemplateVulnInfoKernel())
|
||||
fr.vulnInfos = append(fr.vulnInfos, genmai.GetTemplateVulnInfoSystem())
|
||||
//fr.vulnInfos = append(fr.vulnInfos, "vulnInfos2")
|
||||
//fr.vulnInfos = append(fr.vulnInfos, "vulnInfos3")
|
||||
/* */
|
||||
fr.curVulnInfo = 1
|
||||
fr.curDetailLimitY = 1
|
||||
}
|
||||
|
|
|
@ -94,7 +94,13 @@ func (fr *FrameReport)SetTargetLayout(g *gocui.Gui) error {
|
|||
view.Wrap = false
|
||||
|
||||
for _, rpt := range fr.reports {
|
||||
fmt.Fprintln(view, rpt)
|
||||
// TODO:
|
||||
fmt.Fprintln(view,
|
||||
rpt.GetReportCommon().RCServerName +
|
||||
":" +
|
||||
rpt.GetReportCommon().RCExploredIPv6Addrs[0] +
|
||||
":" +
|
||||
rpt.GetReportCommon().RCExploredIPv4Addrs[0] )
|
||||
} // for _, rp ...
|
||||
|
||||
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET)
|
||||
|
@ -123,7 +129,8 @@ func (fr *FrameReport)SetVulnLayout(g *gocui.Gui) error {
|
|||
view.Editable = false
|
||||
view.Wrap = false
|
||||
|
||||
for _, vinfo := range fr.vulnInfos {
|
||||
// TODO: the initial number:0, not that precise
|
||||
for _, vinfo := range fr.reports[0].GetReportCommon().RCExploredVulns {
|
||||
fmt.Fprintln(view, vinfo)
|
||||
} // for _, rp ...
|
||||
} // if (nil ...
|
||||
|
@ -310,6 +317,9 @@ func (fr *FrameReport)movable(v *gocui.View, nextY int) (ok bool, yLimit int) {
|
|||
case FRAMEREPORTVIEW_VIEWNAME_VULNINFO:
|
||||
// TODO:
|
||||
return false, 0
|
||||
case FRAMEREPORTVIEW_VIEWNAME_REPORT:
|
||||
// TODO:
|
||||
return false, 0
|
||||
default:
|
||||
return true, 0
|
||||
} // switch ( ...
|
||||
|
@ -319,7 +329,7 @@ func (fr *FrameReport)movable(v *gocui.View, nextY int) (ok bool, yLimit int) {
|
|||
func (fr *FrameReport)onMovingCursorRedrawView(g *gocui.Gui, v *gocui.View) error {
|
||||
switch ( v.Name() ) {
|
||||
case FRAMEREPORTVIEW_VIEWNAME_VULN:
|
||||
if rc := fr.redrawVulnInfo(g); (nil != rc) {
|
||||
if rc := fr.redrawViewVulnInfo(g); (nil != rc) {
|
||||
return rc
|
||||
} // if rc := ...
|
||||
case FRAMEREPORTVIEW_VIEWNAME_TARGET:
|
||||
|
@ -328,7 +338,7 @@ func (fr *FrameReport)onMovingCursorRedrawView(g *gocui.Gui, v *gocui.View) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fr *FrameReport)redrawVulnInfo(g *gocui.Gui) error {
|
||||
func (fr *FrameReport)redrawViewVulnInfo(g *gocui.Gui) error {
|
||||
rc := g.DeleteView(FRAMEREPORTVIEW_VIEWNAME_VULNINFO)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
|
|
|
@ -74,7 +74,7 @@ type ReportCommon struct {
|
|||
RCErrors string
|
||||
RCWarnings string
|
||||
|
||||
RCExploredVulns []VulnInfoBase
|
||||
RCExploredVulns []VulnInfoCommon
|
||||
RCReunningKernelInfo ReportKernelInfo
|
||||
RCPackages string // TBD: type
|
||||
RCSrcPackages string // TBD: type
|
||||
|
@ -88,8 +88,12 @@ type ReportBase interface {
|
|||
////////////////////////////////////////////////////////////////
|
||||
// VulnInfo
|
||||
|
||||
type VulnInfoBase interface {
|
||||
}
|
||||
|
||||
// TODO:TBD: 为以后VulnInfo被VulnInfoKernel, VulnInfoSystem继承做
|
||||
// 准备
|
||||
//type VulnInfoBase interface {
|
||||
// GetVulnInfoCommon
|
||||
//}
|
||||
|
||||
// TODO: to complete
|
||||
type VulnInfoCommon struct {
|
||||
|
|
|
@ -41,10 +41,15 @@ type VulnInfoDBus struct {
|
|||
}
|
||||
|
||||
func GetTemplateReportDBus() (*ReportDBus) {
|
||||
var expvuls []VulnInfoBase
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoDBus())
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoDBus())
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoDBus())
|
||||
var expvuls []VulnInfoCommon
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoDBus().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoDBus().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoDBus().VulnInfoCommon)
|
||||
/* */
|
||||
var expip4addr []string
|
||||
expip4addr = append(expip4addr, "0.0.0.0")
|
||||
var expip6addr []string
|
||||
expip6addr = append(expip6addr, "0.0.0.0")
|
||||
/* */
|
||||
return &ReportDBus{
|
||||
ReportCommon {
|
||||
|
@ -60,8 +65,8 @@ func GetTemplateReportDBus() (*ReportDBus) {
|
|||
RCExploredRevision: "RCExploredRevision",
|
||||
RCExploredBy: "RCExploredBy",
|
||||
RCExploredVia: "RCExploredVia",
|
||||
//RCExploredIPv4Addrs:
|
||||
//RCExploredIPv6Addrs:
|
||||
RCExploredIPv4Addrs:expip4addr,
|
||||
RCExploredIPv6Addrs:expip6addr,
|
||||
/* */
|
||||
RCReportedAt: time.Now(),
|
||||
RCReportedVersion: "RCReportedVersion",
|
||||
|
|
|
@ -40,10 +40,15 @@ type VulnInfoKernel struct {
|
|||
}
|
||||
|
||||
func GetTemplateReportKernel() (*ReportKernel) {
|
||||
var expvuls []VulnInfoBase
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel())
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel())
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel())
|
||||
var expvuls []VulnInfoCommon
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel().VulnInfoCommon)
|
||||
/* */
|
||||
var expip4addr []string
|
||||
expip4addr = append(expip4addr, "0.0.0.0")
|
||||
var expip6addr []string
|
||||
expip6addr = append(expip6addr, "0.0.0.0")
|
||||
/* */
|
||||
return &ReportKernel {
|
||||
ReportCommon {
|
||||
|
@ -59,8 +64,8 @@ func GetTemplateReportKernel() (*ReportKernel) {
|
|||
RCExploredRevision: "RCExploredRevision",
|
||||
RCExploredBy: "RCExploredBy",
|
||||
RCExploredVia: "RCExploredVia",
|
||||
//RCExploredIPv4Addrs:
|
||||
//RCExploredIPv6Addrs:
|
||||
RCExploredIPv4Addrs:expip4addr,
|
||||
RCExploredIPv6Addrs:expip6addr,
|
||||
/* */
|
||||
RCReportedAt: time.Now(),
|
||||
RCReportedVersion: "RCReportedVersion",
|
||||
|
@ -88,7 +93,7 @@ func GetTemplateVulnInfoKernel() VulnInfoKernel {
|
|||
VICCveId: "VICCveId",
|
||||
VICConfidences: Confidence {
|
||||
CScore: 123,
|
||||
CDetectionMethod: "CDetectionMethod",
|
||||
CDetectionMethod: "CDetectionMethod-Kernel",
|
||||
SortOrder: 1, },
|
||||
//VICAffectedPackages:
|
||||
// ...
|
||||
|
@ -100,7 +105,6 @@ func GetTemplateVulnInfoKernel() VulnInfoKernel {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// ReportBase methods
|
||||
|
||||
func (rk *ReportKernel)GetReportCommon() ReportCommon {
|
||||
return rk.ReportCommon
|
||||
}
|
||||
|
|
|
@ -41,10 +41,15 @@ type VulnInfoSystem struct {
|
|||
}
|
||||
|
||||
func GetTemplateReportSystem() (*ReportSystem) {
|
||||
var expvuls []VulnInfoBase
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel())
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel())
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel())
|
||||
var expvuls []VulnInfoCommon
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoSystem().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoSystem().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoSystem().VulnInfoCommon)
|
||||
/* */
|
||||
var expip4addr []string
|
||||
expip4addr = append(expip4addr, "0.0.0.0")
|
||||
var expip6addr []string
|
||||
expip6addr = append(expip6addr, "0.0.0.0")
|
||||
/* */
|
||||
return &ReportSystem{
|
||||
ReportCommon {
|
||||
|
@ -60,8 +65,8 @@ func GetTemplateReportSystem() (*ReportSystem) {
|
|||
RCExploredRevision: "RCExploredRevision",
|
||||
RCExploredBy: "RCExploredBy",
|
||||
RCExploredVia: "RCExploredVia",
|
||||
//RCExploredIPv4Addrs:
|
||||
//RCExploredIPv6Addrs:
|
||||
RCExploredIPv4Addrs:expip4addr,
|
||||
RCExploredIPv6Addrs:expip6addr,
|
||||
/* */
|
||||
RCReportedAt: time.Now(),
|
||||
RCReportedVersion: "RCReportedVersion",
|
||||
|
@ -89,7 +94,7 @@ func GetTemplateVulnInfoSystem() (*VulnInfoSystem) {
|
|||
VICCveId: "VICCveId",
|
||||
VICConfidences: Confidence {
|
||||
CScore: 123,
|
||||
CDetectionMethod: "CDetectionMethod",
|
||||
CDetectionMethod: "CDetectionMethod-Kernel",
|
||||
SortOrder: 1, },
|
||||
//VICAffectedPackages:
|
||||
// ...
|
||||
|
|
|
@ -42,10 +42,15 @@ type VulnInfoWeb struct {
|
|||
|
||||
|
||||
func GetTemplateReportWeb() (*ReportWeb) {
|
||||
var expvuls []VulnInfoBase
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoWeb())
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoWeb())
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoWeb())
|
||||
var expvuls []VulnInfoCommon
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoWeb().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoWeb().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoWeb().VulnInfoCommon)
|
||||
/* */
|
||||
var expip4addr []string
|
||||
expip4addr = append(expip4addr, "0.0.0.0")
|
||||
var expip6addr []string
|
||||
expip6addr = append(expip6addr, "0.0.0.0")
|
||||
/* */
|
||||
return &ReportWeb{
|
||||
ReportCommon {
|
||||
|
@ -61,8 +66,8 @@ func GetTemplateReportWeb() (*ReportWeb) {
|
|||
RCExploredRevision: "RCExploredRevision",
|
||||
RCExploredBy: "RCExploredBy",
|
||||
RCExploredVia: "RCExploredVia",
|
||||
//RCExploredIPv4Addrs:
|
||||
//RCExploredIPv6Addrs:
|
||||
RCExploredIPv4Addrs:expip4addr,
|
||||
RCExploredIPv6Addrs:expip6addr,
|
||||
/* */
|
||||
RCReportedAt: time.Now(),
|
||||
RCReportedVersion: "RCReportedVersion",
|
||||
|
@ -90,7 +95,7 @@ func GetTemplateVulnInfoWeb() (*VulnInfoWeb) {
|
|||
VICCveId: "VICCveId",
|
||||
VICConfidences: Confidence {
|
||||
CScore: 123,
|
||||
CDetectionMethod: "CDetectionMethod",
|
||||
CDetectionMethod: "CDetectionMethod-Web",
|
||||
SortOrder: 1, },
|
||||
//VICAffectedPackages:
|
||||
// ...
|
||||
|
|
Loading…
Reference in New Issue