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(scanner/debian): fill kernel version from kernel package #2064

Merged
merged 1 commit into from
Nov 12, 2024
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
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
Loading