Skip to content

Commit

Permalink
Address CR
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa authored and github-actions committed Nov 4, 2024
1 parent 0a6b49c commit 581c155
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/services/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -3247,19 +3247,17 @@ func (set RoleSet) GetAllowedSearchAsRoles(allowFilters ...SearchAsRolesOption)
}
}
for _, role := range set {
if slices.ContainsFunc(allowFilters, func(filter SearchAsRolesOption) bool {
return !filter(role)
}) {
// Don't consider this base role if it's filtered out.
continue
}
for _, a := range role.GetSearchAsRoles(types.Allow) {
filterResult := true
if len(allowFilters) > 0 {
for _, filter := range allowFilters {
if !filter(role) {
filterResult = false
break
}
}
}
if _, ok := denied[a]; !ok && filterResult {
allowed = append(allowed, a)
if _, isDenied := denied[a]; isDenied {
continue
}
allowed = append(allowed, a)
}
}
return apiutils.Deduplicate(allowed)
Expand Down

0 comments on commit 581c155

Please sign in to comment.