Skip to content

Commit

Permalink
fix(scanner/debian): fill kernel version from kernel package
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineK00n committed Nov 11, 2024
1 parent c0b267d commit 0f8b0d9
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions scanner/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
fanal "github.com/aquasecurity/trivy/pkg/fanal/analyzer"
tlog "github.com/aquasecurity/trivy/pkg/log"
xio "github.com/aquasecurity/trivy/pkg/x/io"
debver "github.com/knqyf263/go-deb-version"

"github.com/future-architect/vuls/config"
"github.com/future-architect/vuls/constant"
Expand Down Expand Up @@ -148,19 +147,15 @@ func (l *base) runningKernel() (release, version string, err error) {

switch l.Distro.Family {
case constant.Debian:
r := l.exec("uname -a", noSudo)
r := l.exec(fmt.Sprintf("dpkg-query -W -f='${Version}' linux-image-%s", release), noSudo)
if !r.isSuccess() {
return "", "", xerrors.Errorf("Failed to SSH: %s", r)
}
ss := strings.Fields(r.Stdout)
if 6 < len(ss) {
version = ss[6]
}
if _, err := debver.NewVersion(version); err != nil {
version = ""
l.log.Debugf("Failed to get the running kernel version. err: %s", r.Stderr)
return release, "", nil
}
return release, r.Stdout, nil
default:
return release, "", nil
}
return
}

func (l *base) allContainers() (containers []config.Container, err error) {
Expand Down

0 comments on commit 0f8b0d9

Please sign in to comment.