replace imports of path with path/filepath (#2330)

This commit is contained in:
mmetc 2023-07-26 10:29:58 +02:00 committed by GitHub
parent 1a6f12c88e
commit a01ce18b98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 21 deletions

View file

@ -3,7 +3,7 @@ package parser
import (
"fmt"
"os"
"path"
"path/filepath"
"sort"
"strings"
@ -46,7 +46,7 @@ func Init(c map[string]interface{}) (*UnixParserCtx, error) {
if strings.Contains(f.Name(), ".") {
continue
}
if err := r.Grok.AddFromFile(path.Join(c["patterns"].(string), f.Name())); err != nil {
if err := r.Grok.AddFromFile(filepath.Join(c["patterns"].(string), f.Name())); err != nil {
log.Errorf("failed to load pattern %s : %v", f.Name(), err)
return nil, err
}
@ -97,7 +97,7 @@ func NewParsers() *Parsers {
func LoadParsers(cConfig *csconfig.Config, parsers *Parsers) (*Parsers, error) {
var err error
patternsDir := path.Join(cConfig.Crowdsec.ConfigDir, "patterns/")
patternsDir := filepath.Join(cConfig.Crowdsec.ConfigDir, "patterns/")
log.Infof("Loading grok library %s", patternsDir)
/* load base regexps for two grok parsers */
parsers.Ctx, err = Init(map[string]interface{}{"patterns": patternsDir,