Skip to content

Commit

Permalink
fix(cmd/driver): fixed loadDriverVersion implementation for non-semve…
Browse files Browse the repository at this point in the history
…r driver versions.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP authored and poiana committed Dec 20, 2023
1 parent e6658f0 commit 2e95198
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/driver/driver_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -177,12 +178,23 @@ func NewDriverCmd(ctx context.Context, opt *options.Common) *cobra.Command {
func loadDriverVersion() string {
isSet := false
greatestVrs := semver.Version{}
paths, _ := filepath.Glob("/usr/src/falco-*+driver")
paths, _ := filepath.Glob("/usr/src/falco-*")
for _, path := range paths {
fileInfo, err := os.Stat(path)
// We expect path to point to a folder,
// otherwise skip it.
if err != nil {
continue
}
if !fileInfo.IsDir() {
continue
}
drvVer := strings.TrimPrefix(filepath.Base(path), "falco-")
sv, err := semver.Parse(drvVer)
if err != nil {
continue
// Not a semver; return it because we
// Won't be able to check it against semver driver versions.
return drvVer
}
if sv.GT(greatestVrs) {
greatestVrs = sv
Expand Down

0 comments on commit 2e95198

Please sign in to comment.