Skip to content

Commit

Permalink
fix: preventing index out of range when sa is impersonating
Browse files Browse the repository at this point in the history
  • Loading branch information
prometherion committed Mar 2, 2023
1 parent 3991359 commit da78423
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/webhook/utils/is_capsule_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func IsCapsuleUser(ctx context.Context, req admission.Request, clt client.Client
if sets.NewString(req.UserInfo.Groups...).Has("system:serviceaccounts") {
parts := strings.Split(req.UserInfo.Username, ":")

targetNamespace := parts[2]
if len(parts) == 4 {
targetNamespace := parts[2]

if len(targetNamespace) > 0 {
tl := &capsulev1beta2.TenantList{}
if err := clt.List(ctx, tl, client.MatchingFieldsSelector{Selector: fields.OneTermEqualSelector(".status.namespaces", targetNamespace)}); err != nil {
return false
Expand Down

0 comments on commit da78423

Please sign in to comment.