File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -508,6 +508,12 @@ func (s *Provider) GetGroupsMembersBruteForce(ctx context.Context, gr *model.Gro
508508 // a map of group SCIM IDs to a slice of members
509509 membersByGroup := make (map [string ][]* model.Member )
510510
511+ // pre-initialize all map entries before launching goroutines to avoid
512+ // concurrent map writes between the outer loop and goroutine appends
513+ for _ , group := range gr .Resources {
514+ membersByGroup [group .SCIMID ] = make ([]* model.Member , 0 , 10 )
515+ }
516+
511517 // use an errgroup to manage the goroutines
512518 g , ctx := errgroup .WithContext (ctx )
513519
@@ -520,9 +526,6 @@ func (s *Provider) GetGroupsMembersBruteForce(ctx context.Context, gr *model.Gro
520526 // brute force implemented here thanks to the fxxckin' aws sso scim api
521527 // iterate over each group and user and check if the user is a member of the group
522528 for _ , group := range gr .Resources {
523- // initialize the members slice for the group. Optimistic approach
524- membersByGroup [group .SCIMID ] = make ([]* model.Member , 0 , 10 )
525-
526529 for _ , user := range ur .Resources {
527530
528531 // create a new variable for the group and user to avoid data races
You can’t perform that action at this time.
0 commit comments