Skip to content

Commit

Permalink
fix: resolve homedir when loading external rules (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbadger authored Feb 9, 2023
1 parent a5e8d74 commit a83d7e7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/commands/process/settings/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/bearer/curio/pkg/flag"
"github.com/rs/zerolog/log"
"golang.org/x/exp/maps"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -36,6 +37,11 @@ func loadRules(externalRuleDirs []string, options flag.RuleOptions) (map[string]
}

for _, dir := range externalRuleDirs {
if strings.HasPrefix(dir, "~/") {
dirname, _ := os.UserHomeDir()
dir = filepath.Join(dirname, dir[2:])
}
log.Debug().Msgf("loading external rules from: %s", dir)
if err := loadRuleDefinitions(definitions, os.DirFS(dir)); err != nil {
return nil, nil, fmt.Errorf("error loading external rules from %s: %w", dir, err)
}
Expand Down

0 comments on commit a83d7e7

Please sign in to comment.