Skip to content

Commit

Permalink
fix(provider): fixed OSS provider
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekv24 committed Mar 10, 2025
1 parent 512e6cd commit a52afcc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions plugins/providers/oss/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,11 @@ func policyStatementExist(statement PolicyStatement, resourceAccountID string, g

func addionalPolicyStatementExist(statement PolicyStatement, resourceAccountID string, g domain.Grant) bool {
resourceMatch := slices.Contains(statement.Resource, fmt.Sprintf("acs:oss:*:%s:%s", resourceAccountID, g.Resource.URN))
if !resourceMatch {
if !resourceMatch || len(statement.Action) != 2 {
return false
}

if len(statement.Action) == 2 && resourceMatch {
return slices.Contains(statement.Action, "oss:ListObjects") && slices.Contains(statement.Action, "oss:GetObject")
}

return true
return slices.Contains(statement.Action, "oss:ListObjects") && slices.Contains(statement.Action, "oss:GetObject")
}

func removePrincipalFromPolicy(statement PolicyStatement, principalAccountID string) PolicyStatement {
Expand Down Expand Up @@ -306,7 +302,7 @@ func revokePermissionsFromPolicy(policyString string, g domain.Grant) (string, e
}

skipRemoval := false
for _, s := range bucketPolicy.Statement {
for _, s := range statements {
if &s != &statement && slices.Contains(s.Principal, principalAccountID) && !slices.Contains(s.Action, "oss:*") {
skipRemoval = true
break
Expand Down

0 comments on commit a52afcc

Please sign in to comment.