Skip to content

Commit

Permalink
fix: Fix a possible crash when parsing RBAC (#8165)
Browse files Browse the repository at this point in the history
Signed-off-by: jannfis <jann@mistrust.net>
  • Loading branch information
jannfis committed Jan 13, 2022
1 parent 07cc533 commit 5c85df9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions util/rbac/rbac.go
Expand Up @@ -470,6 +470,12 @@ func loadPolicyLine(line string, model model.Model) error {

key := tokens[0]
sec := key[:1]
if _, ok := model[sec]; !ok {
return fmt.Errorf("invalid RBAC policy: %s", line)
}
if _, ok := model[sec][key]; !ok {
return fmt.Errorf("invalid RBAC policy: %s", line)
}
model[sec][key].Policy = append(model[sec][key].Policy, tokens[1:])
return nil
}
Expand Down

0 comments on commit 5c85df9

Please sign in to comment.