Skip to content

Commit

Permalink
Use copystructure when assigning allowed/denied params from nil check
Browse files Browse the repository at this point in the history
Fixes #4582 -- and even if it doesn't, it's the right thing to do
  • Loading branch information
jefferai committed May 17, 2018
1 parent 8d228fe commit 0615dfd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions vault/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/vault/helper/identity"
"github.com/hashicorp/vault/helper/strutil"
"github.com/hashicorp/vault/logical"
"github.com/mitchellh/copystructure"
)

// ACL is used to wrap a set of policies to provide
Expand Down Expand Up @@ -136,7 +137,11 @@ func NewACL(policies []*Policy) (*ACL, error) {

if len(pc.Permissions.AllowedParameters) > 0 {
if existingPerms.AllowedParameters == nil {
existingPerms.AllowedParameters = pc.Permissions.AllowedParameters
clonedAllowed, err := copystructure.Copy(pc.Permissions.AllowedParameters)
if err != nil {
return nil, err
}
existingPerms.AllowedParameters = clonedAllowed.(map[string][]interface{})
} else {
for key, value := range pc.Permissions.AllowedParameters {
pcValue, ok := existingPerms.AllowedParameters[key]
Expand All @@ -154,7 +159,11 @@ func NewACL(policies []*Policy) (*ACL, error) {

if len(pc.Permissions.DeniedParameters) > 0 {
if existingPerms.DeniedParameters == nil {
existingPerms.DeniedParameters = pc.Permissions.DeniedParameters
clonedDenied, err := copystructure.Copy(pc.Permissions.DeniedParameters)
if err != nil {
return nil, err
}
existingPerms.DeniedParameters = clonedDenied.(map[string][]interface{})
} else {
for key, value := range pc.Permissions.DeniedParameters {
pcValue, ok := existingPerms.DeniedParameters[key]
Expand Down

0 comments on commit 0615dfd

Please sign in to comment.