Skip to content

chore: Cache AuthUsers, Everyone groups for lookup - BED-8363#2822

Open
StephenHinck wants to merge 1 commit into
mainfrom
BED-8363
Open

chore: Cache AuthUsers, Everyone groups for lookup - BED-8363#2822
StephenHinck wants to merge 1 commit into
mainfrom
BED-8363

Conversation

@StephenHinck
Copy link
Copy Markdown
Contributor

@StephenHinck StephenHinck commented May 26, 2026

Description

Centralizes the lookups for specialGroups to prevent recurring lookups during post-processing. In pathological environments, this yielded a 98% reduction in creating the ADCSCache ahead of post-processing.

Motivation and Context

Resolves BED-8363

Why is this change required? What problem does it solve?

How Has This Been Tested?

No changes have been made to existing test suites. Additionally, validated with multiple local datasets.

Screenshots (optional):

Types of changes

  • Chore (a change that does not modify the application functionality)

Checklist:

Summary by CodeRabbit

  • Refactor
    • Optimized cache population to fetch principals once per transaction and reuse them, with improved group membership validation using bulk queries instead of individual lookups.

Review Change Stack

@StephenHinck StephenHinck self-assigned this May 26, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

The changes optimize how special groups (Auth Users and Everyone) are checked for ADCS enrollment rights. Auth Users and Everyone are fetched once per database transaction in BuildCache, then passed to containsAuthUsersOrEveryone for checking, which now uses a single bulk relationship query instead of repeated per-group fetches.

Changes

Special Groups Membership Optimization

Layer / File(s) Summary
containsAuthUsersOrEveryone refactor
packages/go/analysis/ad/esc_shared.go
Function now accepts pre-computed specialGroups instead of fetching internally, and replaces nested relationship-fetch loops with a single bulk MemberOf query to check transitive membership.
BuildCache special groups fetch and reuse
packages/go/analysis/ad/adcscache.go
BuildCache fetches Auth Users and Everyone groups once during the read transaction and reuses them in cert-template and enterprise-CA enrollment checks, passing pre-computed specialGroups into the refactored containsAuthUsersOrEveryone function.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The PR description includes all required sections: Description with motivation (caching reduces lookups by 98%), How Has This Been Tested, Types of changes, and a completed Checklist with verified contributing prerequisites.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title 'Cache AuthUsers, Everyone groups for lookup' directly summarizes the main change: centralizing lookups of special groups to avoid repeated queries, resulting in significant performance improvements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BED-8363

Comment @coderabbitai help to get the list of available commands and usage tips.

@StephenHinck StephenHinck changed the title Cache AuthUsers, Everyone groups for lookup chore: Cache AuthUsers, Everyone groups for lookup - BED-8363 May 26, 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.

1 participant