Security Consolidator

Help ID: guide.security-consolidator

The Security Consolidator collects every permission anomaly across the fleet — orphan users, role bloat, direct grants that should be role-mediated, duplicated effective permissions, and similar — and lets the admin build change scripts to resolve them, one row at a time or many at once.

Rules

A rule is a pure function from a per-instance snapshot (Collector.* views) to zero or more suggestions. Each rule is a single file in Services/Security/Consolidator/Rules/; registering a new rule in ConsolidatorEngine.Rules makes it appear in the grid with no other wiring. V1 ships with four rules covering the fixed database roles:

Rule Direction Scope Roles
Redundant directs Drop grants already covered by a role OBJECT (table/view) db_datareader, db_datawriter
Promote to role Add to role and drop grants that exactly cover it OBJECT (table/view) db_datareader, db_datawriter
Redundant DB-scope Drop DB-scope grants already covered by a role DATABASE db_ddladmin, db_securityadmin, db_accessadmin, db_owner
Promote DB-scope Add to role and drop DB-scope grants covering its practical set DATABASE db_ddladmin, db_securityadmin, db_accessadmin, db_owner

The object-scope rules check every table/view in Collector.SysObjectsCurrent and only emit a Promote suggestion when the principal's direct grants cover every object — exact-cover. The DB-scope rules check against a practical perm list in DbScopeRoleCoverage (the handful of permissions a DBA actually grants manually, not the full textbook list for each role) and only emit Promote when every perm in that list is present. Any DENY on a covered permission skips the Promote suggestion entirely because role membership would flip the principal's effective access.

Grid

Each row is a suggestion. The columns show the server and database the finding applies to, the suggestion category, a short title and a plain-English description of what would change. The grid is grouped, sortable, searchable and filterable through DevExpress's native column affordances — the Consolidator doesn't ship its own filter UI.

Selection

Three ways to pick rows for a bulk build:

  • Tick the checkbox column one row at a time.
  • Select all / Select none buttons in the summary bar for the whole result set.
  • Click a row, then shift-click another to pick the range — the grid's native SelectionMode="MultipleRow" fires SelectedItemChanged, and the Consolidator view mirrors SelectedItems onto each row's IsSelected so the checkbox column and the grid's native selection stay in sync.

Row actions

  • Build (per-row button): opens the Script Action Bar preview with exactly this one suggestion. Useful when the admin wants to eyeball and tweak a single change before queueing.
  • Build all: top-of-grid command that opens the preview with every ticked suggestion. The preview's left-side section pane lists each suggestion by title — one click to jump to it — plus an "All combined" row at the top where every edit lands. See Script Action Bar — Section pane for how the pane behaves.

Both routes go through the same ScriptActionBarVm + PermissionsChangePreviewWindow pair that the Permissions Matrix and Permission Trace drilldown use, so the dispatched Deploy.Code rows, saved library entries and packaged scripts look identical regardless of entry point.

Per-statement split

The Consolidator always knows the exact decomposition of its own script because each suggestion carries its own ApplySql text. SecurityConsolidatorViewModel.BuildPayload runs that text through SplitSqlStatements, a tokenizer that respects:

  • single-quoted string literals,
  • -- line comments and /* … */ block comments,
  • GO batch separators, and
  • bare USE [db] lines and comment-only artifacts — both of which are stripped from the resulting statements list because they don't belong as standalone Deploy.Code rows.

The resulting ScriptActionPayload.Statements list ties each statement back to its suggestion's title and index — {Title} [N/total] when a suggestion produced multiple statements, plain {Title} otherwise.

The payload also sets RecommendSplit = true. This drives the default state of the Split into per-statement rows checkbox on the push-options dialog — it starts ticked for Consolidator and unticked for the Permissions Matrix, because splitting a Matrix cell-level change rarely produces more than one real statement anyway.

When the user keeps the split on and presses Deploy or Schedule, DefaultScriptActionHost.OpenPushOptionsAsync loops the Statements list and calls DeployQueueService.QueueAsync once per statement per target, each time with the per-statement Comment pre-filled. The user's Category stays verbatim on every row — see Deploy.Code Comment column for why Category and Comment are separate fields.

Editing the script

Because the preview's editor is editable, the admin can tweak the generated SQL before it leaves the GUI — change an identifier, add a batch separator, comment out a statement. If the Apply text is edited away from the original, the pre-built Statements list is dropped and the split-per-statement path collapses to a single Deploy.Code row carrying the whole edited blob. See Script Action Bar — Editable editor for the full rule.

Seed data

Scripts/TestData/Consolidator.SeedData.sql populates every Collector base table the scanner reads on a fake instance named MA-CONSOLIDATOR-TEST. Running the script in the Minion DB is idempotent — prior rows for that instance are deleted and the fresh set re-inserted with one ExecutionDateTime. After it runs the Consolidator can scan the fake server and surfaces seven suggestions across all four rules (three Redundant directs, two Promote to role, one Redundant DB-scope, one Promote DB-scope). Use it to demo the tool or to exercise a new rule without needing a real collection run.

Related: Script Action Bar · Permissions Matrix · Deploys · Permission Trace drilldown.

Documentation revision: 2C9E2580EFEFF950