Fix -results-dir option of scan subcommand

This commit is contained in:
Kota Kanbe
2016-09-14 21:36:00 +09:00
parent e6f4d07a87
commit 3c39f1e737
8 changed files with 38 additions and 38 deletions

View File

@@ -33,9 +33,9 @@ import (
// HistoryCmd is Subcommand of list scanned results
type HistoryCmd struct {
debug bool
debugSQL bool
jsonBaseDir string
debug bool
debugSQL bool
resultsDir string
}
// Name return subcommand name
@@ -59,15 +59,15 @@ func (p *HistoryCmd) SetFlags(f *flag.FlagSet) {
f.BoolVar(&p.debugSQL, "debug-sql", false, "SQL debug mode")
wd, _ := os.Getwd()
defaultJSONBaseDir := filepath.Join(wd, "results")
f.StringVar(&p.jsonBaseDir, "results-dir", defaultJSONBaseDir, "/path/to/results")
defaultResultsDir := filepath.Join(wd, "results")
f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results")
}
// Execute execute
func (p *HistoryCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
c.Conf.DebugSQL = p.debugSQL
c.Conf.JSONBaseDir = p.jsonBaseDir
c.Conf.ResultsDir = p.resultsDir
var err error
var jsonDirs report.JSONDirs

View File

@@ -44,7 +44,7 @@ type ScanCmd struct {
configPath string
jsonBaseDir string
resultsDir string
cvedbpath string
cveDictionaryURL string
cacheDBPath string
@@ -126,8 +126,8 @@ func (p *ScanCmd) SetFlags(f *flag.FlagSet) {
defaultConfPath := filepath.Join(wd, "config.toml")
f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml")
defaultJSONBaseDir := filepath.Join(wd, "results")
f.StringVar(&p.jsonBaseDir, "results-dir", defaultJSONBaseDir, "/path/to/results")
defaultResultsDir := filepath.Join(wd, "results")
f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results")
f.StringVar(
&p.cvedbpath,
@@ -347,7 +347,7 @@ func (p *ScanCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
reports = append(reports, report.AzureBlobWriter{})
}
c.Conf.JSONBaseDir = p.jsonBaseDir
c.Conf.ResultsDir = p.resultsDir
c.Conf.CveDBPath = p.cvedbpath
c.Conf.CveDictionaryURL = p.cveDictionaryURL
c.Conf.CacheDBPath = p.cacheDBPath

View File

@@ -33,9 +33,9 @@ import (
// TuiCmd is Subcommand of host discovery mode
type TuiCmd struct {
lang string
debugSQL bool
jsonBaseDir string
lang string
debugSQL bool
resultsDir string
}
// Name return subcommand name
@@ -59,15 +59,15 @@ func (p *TuiCmd) SetFlags(f *flag.FlagSet) {
wd, _ := os.Getwd()
defaultJSONBaseDir := filepath.Join(wd, "results")
f.StringVar(&p.jsonBaseDir, "results-dir", defaultJSONBaseDir, "/path/to/results")
defaultResultsDir := filepath.Join(wd, "results")
f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results")
}
// Execute execute
func (p *TuiCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
c.Conf.Lang = "en"
c.Conf.DebugSQL = p.debugSQL
c.Conf.JSONBaseDir = p.jsonBaseDir
c.Conf.ResultsDir = p.resultsDir
var jsonDirName string
var err error