BED-7634: Azurehound - Fix listResourceGroupUserAccessAdmins filtering by wrong role ID#175
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe role filter in the resource-group user access admin listing was changed from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
d71bba0 to
32af8e9
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/list-resource-group-user-access-admins_test.go (1)
41-45: UnusedmockClientandmockTenantcan be removed.
mockClientis instantiated and configured with aTenantInfo()expectation, but it's never passed tolistResourceGroupUserAccessAdmins(ctx, mockRoleAssignmentsChannel)on line 46. This appears to be leftover from a template or previous implementation.🧹 Suggested cleanup
func TestListResourceGroupUserAccessAdmins(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() ctx := context.Background() - mockClient := mocks.NewMockAzureClient(ctrl) - mockRoleAssignmentsChannel := make(chan azureWrapper[models.ResourceGroupRoleAssignments]) - mockTenant := azure.Tenant{} - mockClient.EXPECT().TenantInfo().Return(mockTenant).AnyTimes() channel := listResourceGroupUserAccessAdmins(ctx, mockRoleAssignmentsChannel)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/list-resource-group-user-access-admins_test.go` around lines 41 - 45, Remove the unused test setup for mockClient and mockTenant: delete the NewMockAzureClient(ctrl) creation, the mockTenant variable, and the mockClient.EXPECT().TenantInfo().Return(mockTenant).AnyTimes() call since mockClient is not passed into listResourceGroupUserAccessAdmins(ctx, mockRoleAssignmentsChannel); ensure mockRoleAssignmentsChannel remains and run tests to confirm no other references to mockClient or mockTenant exist.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cmd/list-resource-group-user-access-admins_test.go`:
- Around line 41-45: Remove the unused test setup for mockClient and mockTenant:
delete the NewMockAzureClient(ctrl) creation, the mockTenant variable, and the
mockClient.EXPECT().TenantInfo().Return(mockTenant).AnyTimes() call since
mockClient is not passed into listResourceGroupUserAccessAdmins(ctx,
mockRoleAssignmentsChannel); ensure mockRoleAssignmentsChannel remains and run
tests to confirm no other references to mockClient or mockTenant exist.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d924cfeb-3f53-4bc3-a3a4-cfe6c848e7e8
📒 Files selected for processing (2)
cmd/list-resource-group-user-access-admins.gocmd/list-resource-group-user-access-admins_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- cmd/list-resource-group-user-access-admins.go
32af8e9 to
ca42246
Compare
Ticket:
BED-7634
Summary:
Fixes the role ID filter in listResourceGroupUserAccessAdmins() — it was using constants.OwnerRoleID instead of constants.UserAccessAdminRoleID, causing Resource Group User Access Admin edges in BloodHound to reflect Owner relationships.
As a result of this, I made another ticket to go and update all the other tests that follow this same pattern since most of them have the same flaw.
Changes:
cmd/list-resource-group-user-access-admins.gocmd/list-resource-group-user-access-admins_test.goResolves BED-7634
Customer Impact
The incorrectly filtered nodes will remain incorrect for up to 7 days in customer envs without adding an additional DB migration. BHE runs auto-pruning operations and deletes all relationship edges whose
lastSeentimestamp is older than BaseTTL (which is 7 days) so when these old (incorrect) edges are left in the env for 7 days and get replaced by the new (valid) nodes, the old ones will be cleaned up. No migration needed.Testing Notes
Refer to the ticket
Demo
ResourceGroupUserAccessAdminsandResourceGroupOwnerswould yield the same results, which was incorrect.Before:
UAAs andOwners of aResourceGroupreturned the same results.After:
UAAs of aResourceGroupnow resolve accurately:Summary by CodeRabbit
Bug Fixes
Tests