From bb12d9dadb54fe383d5c10f5084c74117ba87f4d Mon Sep 17 00:00:00 2001 From: Kota Kanbe Date: Fri, 16 Mar 2018 15:18:10 +0900 Subject: [PATCH] Add diff to TUI (#620) * fix: change ControlPath to .vuls of SSH option (#618) * feat: Add diff option to TUI --- commands/report.go | 2 -- commands/tui.go | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/commands/report.go b/commands/report.go index 53a73f7d..f2eb14e9 100644 --- a/commands/report.go +++ b/commands/report.go @@ -84,7 +84,6 @@ type ReportCmd struct { azureContainer string pipe bool - diff bool } @@ -320,7 +319,6 @@ func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{} c.Conf.Lang = p.lang c.Conf.ResultsDir = p.resultsDir c.Conf.RefreshCve = p.refreshCve - c.Conf.Diff = p.diff c.Conf.CveDBType = p.cveDBType c.Conf.CveDBPath = p.cveDBPath c.Conf.CveDBURL = p.cveDBURL diff --git a/commands/tui.go b/commands/tui.go index 33725520..80383bc3 100644 --- a/commands/tui.go +++ b/commands/tui.go @@ -20,6 +20,7 @@ package commands import ( "context" "flag" + "fmt" "os" "path/filepath" @@ -54,6 +55,7 @@ type TuiCmd struct { ignoreUnfixed bool pipe bool + diff bool } // Name return subcommand name @@ -75,6 +77,7 @@ func (*TuiCmd) Usage() string { [-ovaldb-path=/path/to/oval.sqlite3] [-ovaldb-url=http://127.0.0.1:1324 or DB connection string] [-cvss-over=7] + [-diff] [-ignore-unscored-cves] [-ignore-unfixed] [-results-dir=/path/to/results] @@ -152,6 +155,11 @@ func (p *TuiCmd) SetFlags(f *flag.FlagSet) { 0, "-cvss-over=6.5 means reporting CVSS Score 6.5 and over (default: 0 (means report all))") + f.BoolVar(&p.diff, + "diff", + false, + fmt.Sprintf("Difference between previous result and current result ")) + f.BoolVar( &p.ignoreUnscoredCves, "ignore-unscored-cves", @@ -205,8 +213,15 @@ func (p *TuiCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) s } c.Conf.Pipe = p.pipe + c.Conf.Diff = p.diff - dir, err := report.JSONDir(f.Args()) + var dir string + var err error + if p.diff { + dir, err = report.JSONDir([]string{}) + } else { + dir, err = report.JSONDir(f.Args()) + } if err != nil { util.Log.Errorf("Failed to read from JSON: %s", err) return subcommands.ExitFailure