From b29fc0993b145fb607c0f7f805e6e5aad6223279 Mon Sep 17 00:00:00 2001 From: Lenin Alevski Date: Tue, 30 Nov 2021 21:47:54 -0800 Subject: [PATCH] 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 --- restapi/admin_policies.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/restapi/admin_policies.go b/restapi/admin_policies.go index 58c1bad6e..d517c9709 100644 --- a/restapi/admin_policies.go +++ b/restapi/admin_policies.go @@ -20,6 +20,7 @@ import ( "bytes" "context" "encoding/json" + "fmt" "sort" "strings" @@ -206,13 +207,20 @@ func listPoliciesWithBucket(ctx context.Context, bucket string, client MinioAdmi func policyMatchesBucket(policy *models.Policy, bucket string) bool { policyData := &iampolicy.Policy{} - json.Unmarshal([]byte(policy.Policy), policyData) + err := json.Unmarshal([]byte(policy.Policy), policyData) + if err != nil { + LogError("error parsing policy: %v", err) + return false + } policyStatements := policyData.Statements for i := 0; i < len(policyStatements); i++ { resources := policyStatements[i].Resources if resources.Match(bucket, map[string][]string{}) { return true } + if resources.Match(fmt.Sprintf("%s/*", bucket), map[string][]string{}) { + return true + } } return false }