Skip to content

Commit

Permalink
debug: windows
Browse files Browse the repository at this point in the history
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
  • Loading branch information
denis-tingaikin committed Dec 15, 2022
1 parent 060a864 commit 1b73d1f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/tools/opa/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

const defaultPoliciesDir = "etc/nsm/opa"
Expand Down Expand Up @@ -59,12 +60,17 @@ func PoliciesByFileMask(masks ...string) ([]*AuthorizationPolicy, error) {

func PolicyFromFile(p string) (*AuthorizationPolicy, error) {
// #nosec
p = filepath.FromSlash(p)
b, err := os.ReadFile(p)
if err != nil {
var embedErr error
b, embedErr = embedFS.ReadFile(strings.ReplaceAll(filepath.FromSlash(p), filepath.FromSlash(defaultPoliciesDir), "policies"))
if embedErr != nil {
return nil, errors.Wrap(err, embedErr.Error())
p = strings.ReplaceAll(filepath.FromSlash(p), filepath.FromSlash(defaultPoliciesDir), "policies")
b, embedErr = embedFS.ReadFile(strings.ReplaceAll(p, "\\", "\\\\"))
if embedErr != nil {
return nil, errors.Wrap(err, embedErr.Error())
}
}
}
return &AuthorizationPolicy{
Expand Down Expand Up @@ -103,6 +109,8 @@ func findFilesByPath(mask string) ([]string, error) {

p = filepath.Join(dir, p)

logrus.Error(p)
logrus.Error("regex:" + r.String())
if _, ok := set[p]; !ok && r.MatchString(p) {
result = append(result, p)
set[p] = struct{}{}
Expand Down

0 comments on commit 1b73d1f

Please sign in to comment.