fix(debian,ubuntu): collect running kernel source package (#1935)
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/k0kubun/pp"
|
||||
|
||||
"github.com/future-architect/vuls/constant"
|
||||
)
|
||||
|
||||
func TestMergeNewVersion(t *testing.T) {
|
||||
@@ -428,3 +430,163 @@ func Test_NewPortStat(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenameKernelSourcePackageName(t *testing.T) {
|
||||
type args struct {
|
||||
family string
|
||||
name string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "debian linux-signed -> linux",
|
||||
args: args{
|
||||
family: constant.Debian,
|
||||
name: "linux-signed",
|
||||
},
|
||||
want: "linux",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := RenameKernelSourcePackageName(tt.args.family, tt.args.name); got != tt.want {
|
||||
t.Errorf("RenameKernelSourcePackageName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsKernelSourcePackage(t *testing.T) {
|
||||
type args struct {
|
||||
family string
|
||||
name string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "debian apt",
|
||||
args: args{
|
||||
family: constant.Debian,
|
||||
name: "apt",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "debian linux",
|
||||
args: args{
|
||||
family: constant.Debian,
|
||||
name: "linux",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "debian linux",
|
||||
args: args{
|
||||
family: constant.Debian,
|
||||
name: "linux",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "debian linux-5.10",
|
||||
args: args{
|
||||
family: constant.Debian,
|
||||
name: "linux-5.10",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "debian linux-grsec",
|
||||
args: args{
|
||||
family: constant.Debian,
|
||||
name: "linux-grsec",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "debian linux-base",
|
||||
args: args{
|
||||
family: constant.Debian,
|
||||
name: "linux-base",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "ubuntu apt",
|
||||
args: args{
|
||||
family: constant.Ubuntu,
|
||||
name: "apt",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "ubuntu linux",
|
||||
args: args{
|
||||
family: constant.Ubuntu,
|
||||
name: "linux",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "ubuntu linux-aws",
|
||||
args: args{
|
||||
family: constant.Ubuntu,
|
||||
name: "linux-aws",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "ubuntu linux-5.9",
|
||||
args: args{
|
||||
family: constant.Ubuntu,
|
||||
name: "linux-5.9",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "ubuntu linux-base",
|
||||
args: args{
|
||||
family: constant.Ubuntu,
|
||||
name: "linux-base",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "ubuntu linux-aws-edge",
|
||||
args: args{
|
||||
family: constant.Ubuntu,
|
||||
name: "linux-aws-edge",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "ubuntu linux-aws-5.15",
|
||||
args: args{
|
||||
family: constant.Ubuntu,
|
||||
name: "linux-aws-5.15",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "ubuntu linux-lowlatency-hwe-5.15",
|
||||
args: args{
|
||||
family: constant.Ubuntu,
|
||||
name: "linux-lowlatency-hwe-5.15",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := IsKernelSourcePackage(tt.args.family, tt.args.name); got != tt.want {
|
||||
t.Errorf("IsKernelSourcePackage() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user