Skip to content

Commit

Permalink
Fix: parse OS version
Browse files Browse the repository at this point in the history
  • Loading branch information
wjunLu committed Jul 31, 2024
1 parent 751c88d commit 4fa6f19
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/vulnsrc/openeuler/openeuler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"log"
"path/filepath"
"regexp"
"sort"
"strings"

Expand Down Expand Up @@ -191,9 +192,15 @@ func getAffectedPackages(productTree ProductTree) []Package {
}

func getOSVersion(cpe string) string {
// e.g. cpe:/a:openEuler:openEuler:22.03-LTS-SP3
// e.g., cpe:/a:openEuler:openEuler:22.03-LTS-SP3
parts := strings.Split(cpe, ":")
if len(parts) != 5 || parts[2] != "openEuler" {
// e.g., cpe:/a:openEuler:openEuler-22.03-LTS
pattern := `^openEuler-\d+\.\d+(-LTS(-SP\d+)?)?$`
matched, _ := regexp.MatchString(pattern, parts[len(parts)-1])
if matched {
return parts[len(parts)-1]
}
return ""
}

Expand Down

0 comments on commit 4fa6f19

Please sign in to comment.