mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
prevent memory leak when using control group factors in a policy (#17532)
* prevent a possible memory leak when using control group factors in a policy * CL
This commit is contained in:
3
changelog/17532.txt
Normal file
3
changelog/17532.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
core: prevent memory leak when using control group factors in a policy
|
||||
```
|
||||
@@ -260,7 +260,11 @@ func NewACL(ctx context.Context, policies []*Policy) (*ACL, error) {
|
||||
if pc.Permissions.ControlGroup != nil {
|
||||
if len(pc.Permissions.ControlGroup.Factors) > 0 {
|
||||
if existingPerms.ControlGroup == nil {
|
||||
existingPerms.ControlGroup = pc.Permissions.ControlGroup
|
||||
cg, err := pc.Permissions.ControlGroup.Clone()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
existingPerms.ControlGroup = cg
|
||||
} else {
|
||||
existingPerms.ControlGroup.Factors = append(existingPerms.ControlGroup.Factors, pc.Permissions.ControlGroup.Factors...)
|
||||
}
|
||||
|
||||
@@ -149,6 +149,17 @@ type ControlGroup struct {
|
||||
Factors []*ControlGroupFactor
|
||||
}
|
||||
|
||||
func (c *ControlGroup) Clone() (*ControlGroup, error) {
|
||||
clonedControlGroup, err := copystructure.Copy(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cg := clonedControlGroup.(*ControlGroup)
|
||||
|
||||
return cg, nil
|
||||
}
|
||||
|
||||
type ControlGroupFactor struct {
|
||||
Name string
|
||||
Identity *IdentityFactor `hcl:"identity"`
|
||||
|
||||
Reference in New Issue
Block a user