Skip to content

Commit b29fc09

Browse files
authored
fix: access audit for bucket (#1270)
Policy listing in the Audit list tab was not displaying all the policies with access to the current bucket Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
1 parent a3d0cb3 commit b29fc09

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

restapi/admin_policies.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"context"
2222
"encoding/json"
23+
"fmt"
2324
"sort"
2425
"strings"
2526

@@ -206,13 +207,20 @@ func listPoliciesWithBucket(ctx context.Context, bucket string, client MinioAdmi
206207

207208
func policyMatchesBucket(policy *models.Policy, bucket string) bool {
208209
policyData := &iampolicy.Policy{}
209-
json.Unmarshal([]byte(policy.Policy), policyData)
210+
err := json.Unmarshal([]byte(policy.Policy), policyData)
211+
if err != nil {
212+
LogError("error parsing policy: %v", err)
213+
return false
214+
}
210215
policyStatements := policyData.Statements
211216
for i := 0; i < len(policyStatements); i++ {
212217
resources := policyStatements[i].Resources
213218
if resources.Match(bucket, map[string][]string{}) {
214219
return true
215220
}
221+
if resources.Match(fmt.Sprintf("%s/*", bucket), map[string][]string{}) {
222+
return true
223+
}
216224
}
217225
return false
218226
}

0 commit comments

Comments
 (0)