Skip to content

fix(auth): normalize filters and prevent unbounded filter-based bulk user deletion - #7022

Closed
vjymisal0 wants to merge 3 commits into
devtron-labs:mainfrom
vjymisal0:fix/issue-7020-filter-bulk-delete
Closed

vjymisal0 wants to merge 3 commits into
devtron-labs:mainfrom
vjymisal0:fix/issue-7020-filter-bulk-delete

Conversation

@vjymisal0

Copy link
Copy Markdown

Description

Fixes #7020

Problem

When DELETE /orchestrator/user/bulk is invoked with a listingRequest filter object (e.g. from the UI "select all matching across pages" action) and no explicit ids, getUserIdsHonoringFilters constructed query filters directly without applying the standard normalization (SetDefaultValuesIfNotPresent, setStatusFilterType, and setCurrentTimeInUserInfo). This caused requests targeting a subset (e.g. inactive users) to resolve to all users and deactivate unintended accounts. Furthermore, empty bulk deletion payloads were not rejected prior to execution.

Solution

  1. Filter Normalization: In UserServiceImpl.getUserIdsHonoringFilters, invoke SetDefaultValuesIfNotPresent, setStatusFilterType, and setCurrentTimeInUserInfo before building and executing the filter query.
  2. Payload Validation: Added ValidateBulkDeleteRequest in helper.go to ensure requests contain either concrete IDs or valid filter criteria. Added helper checks on BulkDeleteRequest.
  3. Handler Validation: Added request validation check in UserRestHandlerImpl.BulkDeleteUsers to reject malformed/empty payloads with HTTP 400.
  4. Testing: Added unit tests covering ValidateBulkDeleteRequest and BulkDeleteUsers in helper_test.go and UserService_test.go.

Files Changed:

  • api/auth/user/UserRestHandler.go
  • pkg/auth/user/UserService.go
  • pkg/auth/user/UserService_test.go
  • pkg/auth/user/bean/UserRequest.go
  • pkg/auth/user/helper/helper.go
  • pkg/auth/user/helper/helper_test.go

@bito-code-review

Copy link
Copy Markdown

Bito Review Skipped - Source Branch Not Found

Bito didn't review this change because the pull request is no longer valid. It may have been merged, or the source/target branch may no longer exist.

@vjymisal0
vjymisal0 force-pushed the fix/issue-7020-filter-bulk-delete branch from 16d9f9f to 07ce58e Compare September 13, 2026 04:48
@vjymisal0
vjymisal0 force-pushed the fix/issue-7020-filter-bulk-delete branch from 07ce58e to bf3cc29 Compare September 21, 2026 06:35
Copilot AI balanced review requested due to automatic review settings October 8, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

@vjymisal0

Copy link
Copy Markdown
Author

Closing this as superseded: 4b2bf38 ("fix(user): scope filter-based bulk delete to match listing filters") already fixed #7020 on main. Thanks for the fix!

@vjymisal0 vjymisal0 closed this Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Filter-based bulk user delete (DELETE /orchestrator/user/bulk) deletes far more users than the filter implies

2 participants