Skip to content

Commit

Permalink
fix: disable policy rule compaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu Jian committed Jun 16, 2020
1 parent 6cedfa3 commit 818d40c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
26 changes: 0 additions & 26 deletions pkg/util/rbacutils/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,32 +252,6 @@ func GetMatchRule(rules []SRbacRule, service string, resource string, action str
return matchRule
}

func CompactRules(rules []SRbacRule) []SRbacRule {
if len(rules) == 0 {
return nil
}
/*output := make([]SRbacRule, 1)
output[0] = rules[0]
for i := 1; i < len(rules); i += 1 {
isContains := false
for j := 0; j < len(output); j += 1 {
if output[j].contains(&rules[i]) {
isContains = true
break
}
if rules[i].contains(&output[j]) {
output[j] = rules[i]
isContains = true
break
}
}
if !isContains {
output = append(output, rules[i])
}
}*/
return reduceRules(rules)
}

var (
tenantEqualsPattern = regexp.MustCompile(`tenant\s*==\s*['"]?(\w+)['"]?`)
roleContainsPattern = regexp.MustCompile(`roles.contains\(['"]?(\w+)['"]?\)`)
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/rbacutils/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func rules2Json(rules []SRbacRule) jsonutils.JSONObject {
for _, r := range rules {
root.AddRule(r)
}
root.reduce()
// root.reduce()
return root.json()
}

Expand All @@ -250,7 +250,7 @@ func json2Rules(json jsonutils.JSONObject) ([]SRbacRule, error) {
if err != nil {
return nil, errors.Wrap(err, "root.parseJson")
}
root.reduce()
// root.reduce()
return root.GetRules(), nil
}

Expand Down

0 comments on commit 818d40c

Please sign in to comment.