* refactor(scan): remove yum-security related code * fix(reporting): error if no OVAL entry
97 lines
2.0 KiB
Go
97 lines
2.0 KiB
Go
package scan
|
|
|
|
import (
|
|
"github.com/future-architect/vuls/config"
|
|
"github.com/future-architect/vuls/models"
|
|
"github.com/future-architect/vuls/util"
|
|
)
|
|
|
|
// inherit OsTypeInterface
|
|
type oracle struct {
|
|
redhatBase
|
|
}
|
|
|
|
// NewAmazon is constructor
|
|
func newOracle(c config.ServerInfo) *oracle {
|
|
r := &oracle{
|
|
redhatBase{
|
|
base: base{
|
|
osPackages: osPackages{
|
|
Packages: models.Packages{},
|
|
VulnInfos: models.VulnInfos{},
|
|
},
|
|
},
|
|
sudo: rootPrivOracle{},
|
|
},
|
|
}
|
|
r.log = util.NewCustomLogger(c)
|
|
r.setServerInfo(c)
|
|
return r
|
|
}
|
|
|
|
func (o *oracle) checkScanMode() error {
|
|
return nil
|
|
}
|
|
|
|
func (o *oracle) checkDeps() error {
|
|
if o.getServerInfo().Mode.IsFast() {
|
|
return o.execCheckDeps(o.depsFast())
|
|
} else if o.getServerInfo().Mode.IsFastRoot() {
|
|
return o.execCheckDeps(o.depsFastRoot())
|
|
} else {
|
|
return o.execCheckDeps(o.depsDeep())
|
|
}
|
|
}
|
|
|
|
func (o *oracle) depsFast() []string {
|
|
if o.getServerInfo().Mode.IsOffline() {
|
|
return []string{}
|
|
}
|
|
// repoquery
|
|
return []string{"yum-utils"}
|
|
}
|
|
|
|
func (o *oracle) depsFastRoot() []string {
|
|
return []string{"yum-utils"}
|
|
}
|
|
|
|
func (o *oracle) depsDeep() []string {
|
|
return o.depsFastRoot()
|
|
}
|
|
|
|
func (o *oracle) checkIfSudoNoPasswd() error {
|
|
if o.getServerInfo().Mode.IsFast() {
|
|
return o.execCheckIfSudoNoPasswd(o.sudoNoPasswdCmdsFast())
|
|
} else if o.getServerInfo().Mode.IsFastRoot() {
|
|
return o.execCheckIfSudoNoPasswd(o.sudoNoPasswdCmdsFastRoot())
|
|
} else {
|
|
return o.execCheckIfSudoNoPasswd(o.sudoNoPasswdCmdsDeep())
|
|
}
|
|
}
|
|
|
|
func (o *oracle) sudoNoPasswdCmdsFast() []cmd {
|
|
return []cmd{}
|
|
}
|
|
|
|
func (o *oracle) sudoNoPasswdCmdsFastRoot() []cmd {
|
|
cmds := []cmd{{"needs-restarting", exitStatusZero}}
|
|
if o.getServerInfo().Mode.IsOffline() {
|
|
return cmds
|
|
}
|
|
return append(cmds, cmd{"repoquery -h", exitStatusZero})
|
|
}
|
|
|
|
func (o *oracle) sudoNoPasswdCmdsDeep() []cmd {
|
|
return o.sudoNoPasswdCmdsFastRoot()
|
|
}
|
|
|
|
type rootPrivOracle struct{}
|
|
|
|
func (o rootPrivOracle) repoquery() bool {
|
|
return true
|
|
}
|
|
|
|
func (o rootPrivOracle) yumMakeCache() bool {
|
|
return true
|
|
}
|