mirror of
https://github.com/aquasecurity/linux-bench.git
synced 2025-02-23 14:45:33 +01:00
gets also ubuntu version
There are differences between Ubuntu 16 and Ubuntu 18 features so the system needs to know the specific version
This commit is contained in:
parent
8fc2a4643b
commit
43081d61f2
1 changed files with 6 additions and 1 deletions
7
utils.go
7
utils.go
|
@ -104,11 +104,16 @@ func GetLSM() (lsm string, err error) {
|
||||||
func getPlatformVersion(output, platform string) string {
|
func getPlatformVersion(output, platform string) string {
|
||||||
flagRe := regexp.MustCompile("version_id" + `=([^ \n]*)`)
|
flagRe := regexp.MustCompile("version_id" + `=([^ \n]*)`)
|
||||||
vals := flagRe.FindStringSubmatch(output)
|
vals := flagRe.FindStringSubmatch(output)
|
||||||
|
if vals == nil {
|
||||||
|
flagRe := regexp.MustCompile("version" + `=([^ \n]*)`)
|
||||||
|
vals = flagRe.FindStringSubmatch(output)
|
||||||
|
}
|
||||||
if len(vals) > 1 {
|
if len(vals) > 1 {
|
||||||
switch platform {
|
switch platform {
|
||||||
case "rhel":
|
case "rhel":
|
||||||
return vals[1][:1] // Get the major version only, examaple: 7.6 will return 7
|
return vals[1][:1] // Get the major version only, examaple: 7.6 will return 7
|
||||||
|
case "ubuntu":
|
||||||
|
return vals[1][:2] // Get the major version only, examaple: 18.04 will return 18
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue