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

Add timeout option to configtest #400

Merged
merged 1 commit into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ configtest:
[-log-dir=/path/to/log]
[-ask-key-password]
[-ssh-external]
[-timeout=300]
[-http-proxy=http://192.168.0.1:8080]
[-debug]

Expand All @@ -684,6 +685,8 @@ configtest:
/path/to/log (default "/var/log/vuls")
-ssh-external
Use external ssh command. Default: Use the Go native implementation
-timeout int
Timeout(Sec) (default 300)
```

configtestサブコマンドは以下をチェックする
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ configtest:
[-log-dir=/path/to/log]
[-ask-key-password]
[-ssh-external]
[-timeout=300]
[-debug]

[SERVER]...
Expand All @@ -691,6 +692,9 @@ configtest:
/path/to/log (default "/var/log/vuls")
-ssh-external
Use external ssh command. Default: Use the Go native implementation
-timeout int
Timeout(Sec) (default 300)

```

The configtest subcommand checks the following
Expand Down
8 changes: 6 additions & 2 deletions commands/configtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ConfigtestCmd struct {
askKeyPassword bool
sshExternal bool
httpProxy string
timeoutSec int

debug bool
}
Expand All @@ -54,6 +55,7 @@ func (*ConfigtestCmd) Usage() string {
[-config=/path/to/config.toml]
[-log-dir=/path/to/log]
[-ask-key-password]
[-timeout=300]
[-ssh-external]
[-http-proxy=http://192.168.0.1:8080]
[-debug]
Expand All @@ -73,6 +75,8 @@ func (p *ConfigtestCmd) SetFlags(f *flag.FlagSet) {

f.BoolVar(&p.debug, "debug", false, "debug mode")

f.IntVar(&p.timeoutSec, "timeout", 5*60, "Timeout(Sec)")

f.BoolVar(
&p.askKeyPassword,
"ask-key-password",
Expand Down Expand Up @@ -157,10 +161,10 @@ func (p *ConfigtestCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interfa
}

util.Log.Info("Checking dependendies...")
scan.CheckDependencies()
scan.CheckDependencies(p.timeoutSec)

util.Log.Info("Checking sudo settings...")
scan.CheckIfSudoNoPasswd()
scan.CheckIfSudoNoPasswd(p.timeoutSec)

scan.PrintSSHableServerNames()
return subcommands.ExitSuccess
Expand Down
6 changes: 2 additions & 4 deletions scan/serverapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,15 @@ func detectContainerOSesOnServer(containerHost osTypeInterface) (oses []osTypeIn
}

// CheckDependencies checks dependencies are installed on target servers.
func CheckDependencies() {
timeoutSec := 5 * 60
func CheckDependencies(timeoutSec int) {
parallelExec(func(o osTypeInterface) error {
return o.checkDependencies()
}, timeoutSec)
return
}

// CheckIfSudoNoPasswd checks whether vuls can sudo with nopassword via SSH
func CheckIfSudoNoPasswd() {
timeoutSec := 5 * 60
func CheckIfSudoNoPasswd(timeoutSec int) {
parallelExec(func(o osTypeInterface) error {
return o.checkIfSudoNoPasswd()
}, timeoutSec)
Expand Down