Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to read config.toml at tui #441

Merged
merged 2 commits into from
Aug 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions commands/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import (

// TuiCmd is Subcommand of host discovery mode
type TuiCmd struct {
lang string
debugSQL bool
debug bool
logDir string
lang string
debugSQL bool
debug bool
configPath string
logDir string

resultsDir string
refreshCve bool
Expand All @@ -56,6 +57,7 @@ func (*TuiCmd) Synopsis() string { return "Run Tui view to anayze vulnerabilites
func (*TuiCmd) Usage() string {
return `tui:
tui
[-config=/path/to/config.toml]
[-cvedb-type=sqlite3|mysql|postgres]
[-cvedb-path=/path/to/cve.sqlite3]
[-cvedb-url=http://127.0.0.1:1323 or DB connection string]
Expand All @@ -82,6 +84,9 @@ func (p *TuiCmd) SetFlags(f *flag.FlagSet) {
defaultResultsDir := filepath.Join(wd, "results")
f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results")

defaultConfPath := filepath.Join(wd, "config.toml")
f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml")

f.BoolVar(
&p.refreshCve,
"refresh-cve",
Expand Down Expand Up @@ -125,6 +130,11 @@ func (p *TuiCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) s
util.Log = util.NewCustomLogger(c.ServerInfo{})
log := util.Log

if err := c.Load(p.configPath, ""); err != nil {
util.Log.Errorf("Error loading %s, %s", p.configPath, err)
return subcommands.ExitUsageError
}

c.Conf.ResultsDir = p.resultsDir
c.Conf.CveDBType = p.cvedbtype
c.Conf.CveDBPath = p.cvedbpath
Expand Down