Skip to content

Commit

Permalink
Increase max rule nesting depth to 10 (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluekeyes authored Aug 14, 2020
1 parent ddf502f commit b1e33e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion policy/approval/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (p Policy) Parse(rules map[string]*Rule) (common.Evaluator, error) {
}

func parsePolicyR(policy interface{}, rules map[string]*Rule, depth int) (common.Evaluator, error) {
if depth > 5 {
if depth > 10 {
return nil, errors.New("reached maximum recursive depth while processing policy")
}

Expand Down
26 changes: 18 additions & 8 deletions policy/approval/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,18 @@ func TestParsePolicyError_multikey(t *testing.T) {
}

func TestParsePolicyError_recursiveDepth(t *testing.T) {
// Recursive depth 5 is allowed
// Recursive depth 10 is allowed
policy := `
- or:
- or:
- or:
- or:
- or:
- or:
- rule1
- or:
- or:
- or:
- or:
- or:
- rule1
`

rules := `
Expand All @@ -208,14 +213,19 @@ func TestParsePolicyError_recursiveDepth(t *testing.T) {
_, err := loadAndParsePolicy(t, policy, rules)
require.NoError(t, err)

// Recursive depth 6 is not allowed
// Recursive depth 11 is not allowed
policy = `
- or:
- or:
- or:
- or:
- or:
- or:
- or:
- or:
- or:
- rule1
- or:
- or:
- or:
- rule1
`

_, err = loadAndParsePolicy(t, policy, rules)
Expand Down

0 comments on commit b1e33e1

Please sign in to comment.