Skip to content

Commit f2e2739

Browse files
authored
fix(gcs): exclude deleted principals (#364)
* refactor(gcs): use account type whitelisting * fix(gcs): exclude deleted principals
1 parent 3a88ce9 commit f2e2739

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

plugins/providers/gcs/client.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import (
1313
"google.golang.org/api/option"
1414
)
1515

16-
var (
17-
excludedAccountTypesOnImport = []string{"allUsers", "allAuthenticatedUsers", "projectOwner", "projectEditor", "projectViewer"}
18-
)
19-
2016
type gcsClient struct {
2117
client *storage.Client
2218
projectID string
@@ -99,13 +95,16 @@ func (c *gcsClient) ListAccess(ctx context.Context, resources []*domain.Resource
9995

10096
for _, role := range policy.Roles() {
10197
for _, member := range policy.Members(role) {
98+
if strings.HasPrefix(member, "deleted:") {
99+
continue
100+
}
102101
accountType, accountID, err := parseMember(member)
103102
if err != nil {
104103
return nil, err
105104
}
106105

107106
// exclude unsupported account types
108-
if utils.ContainsString(excludedAccountTypesOnImport, accountType) {
107+
if !utils.ContainsString(AllowedAccountTypes, accountType) {
109108
continue
110109
}
111110

plugins/providers/gcs/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ const (
2828
AccountTypeDomain = "domain"
2929
)
3030

31+
var (
32+
AllowedAccountTypes = []string{
33+
AccountTypeUser,
34+
AccountTypeServiceAccount,
35+
AccountTypeGroup,
36+
AccountTypeDomain,
37+
}
38+
)
39+
3140
type Config struct {
3241
ProviderConfig *domain.ProviderConfig
3342

0 commit comments

Comments
 (0)