mirror of
https://github.com/datarhei/core.git
synced 2025-11-02 12:14:12 +08:00
Fix leaking slices
This commit is contained in:
@@ -29,23 +29,17 @@ func (a *policyAdapter) LoadPolicy(model policy.Model) error {
|
||||
domains := map[string]struct{}{}
|
||||
|
||||
for _, p := range storePolicies.Policies {
|
||||
if len(p.Domain) == 0 {
|
||||
p.Domain = "$none"
|
||||
policy := p.Clone()
|
||||
|
||||
if len(policy.Domain) == 0 {
|
||||
policy.Domain = "$none"
|
||||
}
|
||||
|
||||
if len(p.Types) == 0 {
|
||||
p.Types = []string{"$none"}
|
||||
if len(policy.Types) == 0 {
|
||||
policy.Types = []string{"$none"}
|
||||
}
|
||||
|
||||
policy := policy.Policy{
|
||||
Name: p.Name,
|
||||
Domain: p.Domain,
|
||||
Types: p.Types,
|
||||
Resource: p.Resource,
|
||||
Actions: p.Actions,
|
||||
}
|
||||
|
||||
domains[p.Domain] = struct{}{}
|
||||
domains[policy.Domain] = struct{}{}
|
||||
|
||||
policies = append(policies, policy)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,9 @@ func (s *store) IAMPolicyList() Policies {
|
||||
}
|
||||
|
||||
for _, policies := range s.data.Policies.Policies {
|
||||
p.Policies = append(p.Policies, policies...)
|
||||
for _, pol := range policies {
|
||||
p.Policies = append(p.Policies, pol.Clone())
|
||||
}
|
||||
}
|
||||
|
||||
return p
|
||||
@@ -74,7 +76,10 @@ func (s *store) IAMIdentityPolicyList(name string) Policies {
|
||||
}
|
||||
|
||||
p.UpdatedAt = user.UpdatedAt
|
||||
p.Policies = append(p.Policies, s.data.Policies.Policies[user.Name]...)
|
||||
|
||||
for _, pol := range s.data.Policies.Policies[user.Name] {
|
||||
p.Policies = append(p.Policies, pol.Clone())
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user