Skip to content

Commit

Permalink
fix(gcs): exclude deleted principals (#364)
Browse files Browse the repository at this point in the history
* refactor(gcs): use account type whitelisting

* fix(gcs): exclude deleted principals
  • Loading branch information
rahmatrhd authored Feb 17, 2023
1 parent 3a88ce9 commit f2e2739
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugins/providers/gcs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import (
"google.golang.org/api/option"
)

var (
excludedAccountTypesOnImport = []string{"allUsers", "allAuthenticatedUsers", "projectOwner", "projectEditor", "projectViewer"}
)

type gcsClient struct {
client *storage.Client
projectID string
Expand Down Expand Up @@ -99,13 +95,16 @@ func (c *gcsClient) ListAccess(ctx context.Context, resources []*domain.Resource

for _, role := range policy.Roles() {
for _, member := range policy.Members(role) {
if strings.HasPrefix(member, "deleted:") {
continue
}
accountType, accountID, err := parseMember(member)
if err != nil {
return nil, err
}

// exclude unsupported account types
if utils.ContainsString(excludedAccountTypesOnImport, accountType) {
if !utils.ContainsString(AllowedAccountTypes, accountType) {
continue
}

Expand Down
9 changes: 9 additions & 0 deletions plugins/providers/gcs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ const (
AccountTypeDomain = "domain"
)

var (
AllowedAccountTypes = []string{
AccountTypeUser,
AccountTypeServiceAccount,
AccountTypeGroup,
AccountTypeDomain,
}
)

type Config struct {
ProviderConfig *domain.ProviderConfig

Expand Down

0 comments on commit f2e2739

Please sign in to comment.