Skip to content

Commit

Permalink
update(pkg/kernelrelease): update kernelrelease regex to match more k…
Browse files Browse the repository at this point in the history
…ernels.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
  • Loading branch information
FedeDP authored and poiana committed Apr 23, 2024
1 parent 00c7e79 commit f077720
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/kernelrelease/kernelrelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

var (
kernelVersionPattern = regexp.MustCompile(`(?P<fullversion>^(?P<version>0|[1-9]\d*)\.(?P<patchlevel>0|[1-9]\d*)[.+]?(?P<sublevel>0|[1-9]\d*)?)(?P<fullextraversion>[-.+](?P<extraversion>0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)([\.+~](0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-_]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$`)
kernelVersionPattern = regexp.MustCompile(`(?P<fullversion>^(?P<version>0|[1-9]\d*)\.(?P<patchlevel>0|[1-9]\d*)[.+]?(?P<sublevel>0|[1-9]\d*)?)(?P<fullextraversion>[-.+](?P<extraversion>\d+|\d*[a-zA-Z-][0-9a-zA-Z-]*)([\.+~](\d+|\d*[a-zA-Z-][0-9a-zA-Z-_]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$`)
)

const (
Expand Down
14 changes: 14 additions & 0 deletions pkg/kernelrelease/kernelrelease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ func TestFromString(t *testing.T) {
FullExtraversion: "+deb10u4~bpo9+1",
},
},
// See https://github.com/falcosecurity/falco/issues/3172
"strange tencentos version": {
kernelVersionStr: "5.4.119-19.0009.28",
want: KernelRelease{
Fullversion: "5.4.119",
Version: semver.Version{
Major: 5,
Minor: 4,
Patch: 119,
},
Extraversion: "19",
FullExtraversion: "-19.0009.28",
},
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
Expand Down

0 comments on commit f077720

Please sign in to comment.