diff --git a/commands/prepare.go b/commands/prepare.go index 79ef2643..5ca45324 100644 --- a/commands/prepare.go +++ b/commands/prepare.go @@ -78,7 +78,7 @@ func (p *PrepareCmd) SetFlags(f *flag.FlagSet) { // Execute execute func (p *PrepareCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { - logrus.Infof("Begin Preparing (config: %s)", p.configPath) + logrus.Infof("Start Preparing (config: %s)", p.configPath) err := c.Load(p.configPath) if err != nil { diff --git a/commands/scan.go b/commands/scan.go index 1764aa11..137b4150 100644 --- a/commands/scan.go +++ b/commands/scan.go @@ -130,7 +130,7 @@ func (p *ScanCmd) SetFlags(f *flag.FlagSet) { // Execute execute func (p *ScanCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { - logrus.Infof("Begin scanning (config: %s)", p.configPath) + logrus.Infof("Start scanning (config: %s)", p.configPath) err := c.Load(p.configPath) if err != nil { logrus.Errorf("Error loading %s, %s", p.configPath, err) @@ -192,10 +192,10 @@ func (p *ScanCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) return subcommands.ExitFailure } - Log.Info("Detecting OS... ") + Log.Info("Detecting the type of OS... ") err = scan.InitServers(Log) if err != nil { - Log.Errorf("Failed to init servers. err: %s", err) + Log.Errorf("Failed to init servers. Check the configuration. err: %s", err) return subcommands.ExitFailure } diff --git a/scan/linux.go b/scan/linux.go index 4002caf8..14861a2b 100644 --- a/scan/linux.go +++ b/scan/linux.go @@ -18,6 +18,7 @@ along with this program. If not, see . package scan import ( + "fmt" "sort" "github.com/Sirupsen/logrus" @@ -52,6 +53,10 @@ func (l *linux) setDistributionInfo(fam, rel string) { l.Release = rel } +func (l *linux) getDistributionInfo() string { + return fmt.Sprintf("%s %s", l.Family, l.Release) +} + func (l *linux) convertToModel() (models.ScanResult, error) { var cves, unknownScoreCves []models.CveInfo for _, p := range l.UnsecurePackages { diff --git a/scan/redhat.go b/scan/redhat.go index 0d80fcf5..97042d75 100644 --- a/scan/redhat.go +++ b/scan/redhat.go @@ -51,7 +51,7 @@ func detectRedhat(c config.ServerInfo) (itsMe bool, red osTypeInterface) { red = newRedhat(c) // set sudo option flag - c.SudoOpt = config.SudoOption{ExecBySudoSh: true} + c.SudoOpt = config.SudoOption{ExecBySudo: true} red.setServerInfo(c) if r := sshExec(c, "ls /etc/fedora-release", noSudo); r.isSuccess() { diff --git a/scan/serverapi.go b/scan/serverapi.go index dda7bc0b..8f116650 100644 --- a/scan/serverapi.go +++ b/scan/serverapi.go @@ -21,6 +21,7 @@ type osTypeInterface interface { setServerInfo(config.ServerInfo) getServerInfo() config.ServerInfo setDistributionInfo(string, string) + getDistributionInfo() string checkRequiredPackagesInstalled() error scanPackages() error scanVulnByCpeName() error @@ -108,7 +109,7 @@ func detectOs(c config.ServerInfo) (osType osTypeInterface) { func InitServers(localLogger *logrus.Entry) (err error) { Log = localLogger if servers, err = detectServersOS(); err != nil { - err = fmt.Errorf("Failed to detect OS") + err = fmt.Errorf("Failed to detect the type of OS. err: %s", err) } else { Log.Debugf("%s", pp.Sprintf("%s", servers)) } @@ -128,10 +129,26 @@ func detectServersOS() (osi []osTypeInterface, err error) { for i := 0; i < len(config.Conf.Servers); i++ { select { case res := <-osTypeChan: + Log.Infof("(%d/%d) Successfully detected. %s: %s", + i+1, len(config.Conf.Servers), + res.getServerInfo().ServerName, + res.getDistributionInfo()) osi = append(osi, res) case <-timeout: - Log.Error("Timeout occured while detecting OS") - err = fmt.Errorf("Timeout!") + Log.Error("Timeout occured while detecting") + err = fmt.Errorf("Timeout") + for servername := range config.Conf.Servers { + found := false + for _, o := range osi { + if servername == o.getServerInfo().ServerName { + found = true + break + } + } + if !found { + Log.Errorf("Failed to detect. servername: %s", servername) + } + } return } } @@ -151,7 +168,7 @@ func Prepare() []error { // Scan scan func Scan() []error { if len(servers) == 0 { - return []error{fmt.Errorf("Not initialized yet")} + return []error{fmt.Errorf("No server defined. Check the configuration")} } Log.Info("Check required packages for scanning...")