audit-permissions — Claude Code skill: what it does, how to install
audit-permissions audits Power Pages table permissions against site code and Dataverse metadata, grades the setup on a 1–5 scale, and generates an HTML report.
MIT ★ 1,167 updated 2026-10-29
/plugin marketplace add microsoft/power-platform-skills
/plugin install power-pages@power-platform-skillsWhat audit-permissions does
The skill evaluates table permissions across Power Pages sites by checking them against client-side code and Dataverse metadata. It relies on an A–K checklist to spot missing CRUD flags, $expand gaps, broken relationship chains, and over-provisioned access. Both SPA sites and PAC-downloaded projects are supported.
Under the hood, the workflow calls Node.js utility scripts to discover lookup columns and validate schemas. The agent classifies findings into major or minor issues using a recurring-issue catalog. Each major finding receives an attribution tag showing whether the root cause lies in permissions alone or in upstream code. The final 1–5 scores follow a deterministic formula instead of freeform model estimates.
Execution requires Node.js in the environment alongside access to the Dataverse instance and the .powerpages-site folder.
What it helps with
- audit Power Pages table permissions against actual code usage
- detect missing CRUD operations and over-privileged table access
- generate an HTML audit report with 1–5 category ratings
- trace permission defects back to upstream code or misconfigured grants
Example prompts for the agent
- Audit table permissions for this Power Pages site and generate an HTML report.
- Check permissions on the
contacttable against our site code. - Score our Power Pages security setup before deployment.
How to install audit-permissions
1Plugin marketplace
/plugin marketplace add microsoft/power-platform-skills/plugin install power-pages@power-platform-skillsThis installs the whole power-pages plugin with all its skills
2Skills CLI (Vercel)
npx skills add microsoft/power-platform-skills --skill audit-permissions -a claude-code3Manually: put the files in place
~/.claude/skills/audit-permissions/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/audit-permissions/
1Skills CLI (Vercel)
npx skills add microsoft/power-platform-skills --skill audit-permissions -a codex2Manually: put the files in place
.agents/skills/audit-permissions/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add microsoft/power-platform-skills --skill audit-permissions -a cursor2Manually: put the files in place
.cursor/skills/audit-permissions/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install microsoft/power-platform-skills plugins/power-pages/skills/audit-permissions2Manually: put the files in place
.github/skills/audit-permissions/SKILL.md1Skills CLI (Vercel)
npx skills add microsoft/power-platform-skills --skill audit-permissions -a gemini-cli2Platform CLI
gemini skills install https://github.com/microsoft/power-platform-skills --path plugins/power-pages/skills/audit-permissionsManually: put the files in place
.devin/skills/audit-permissions/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about audit-permissions
How to install audit-permissions in Claude Code?
Register the marketplace with /plugin marketplace add microsoft/power-platform-skills, then install the package with /plugin install power-pages@power-platform-skills.
What does audit-permissions do?
It inspects Power Pages permissions against site code and Dataverse relationships, flags major or minor flaws, and calculates deterministic 1–5 category scores.
How does the scoring system work?
The skill counts detected issues across nine dimensions and applies a strict mathematical formula. Runs on identical configurations always yield identical 1–5 scores.
Source text
SKILL.md · MIT
---
name: audit-permissions
description: >-
Audits existing table permissions on a Power Pages site by analyzing them against site code
and Dataverse metadata, then GRADES the configuration with deterministic 1–5 scores across
3 security/usability/correctness categories (9 dimensions). Detection is anchored by a
recurring-issue catalog so findings and severities stay consistent run-to-run. Generates an
HTML report with an at-a-glance verdict and per-category scores in the Overview plus a
single list of **major/minor** issues (each major issue labelled permissions-only or upstream-caused with a short justification), and suggested fixes.
Use when the user wants to review, verify, check, score,
or grade table permissions for security issues. Supports SPA and PAC-downloaded non-SPA sites.
user-invocable: true
argument-hint: "[optional: specific table or concern]"
allowed-tools: Read, Write, Bash, Glob, Grep, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, Agent
model: opus
---
> **Plugin check**: Run `node "${PLUGIN_ROOT}/scripts/check-version.js"` — if it outputs a message, show it to the user before proceeding.
# Audit Permissions
Audit existing table permissions on a Power Pages code site. Analyze permissions against the site code and Dataverse metadata, then generate a visual HTML report with **deterministic 1–5 category scores**, an advisory verdict, findings, reasoning, and suggested fixes.
The skill has two parts:
1. **Audit checks** (evidence + remediation) — the per-table A–K checklist that compares every permission against real code usage and Dataverse metadata. It is the **primary issue detector**: it catches concrete, code-grounded problems (missing CRUD, append/appendto, `$expand` gaps, broken parent chains, over-provisioned grants) and emits each as a **major/minor** issue with concrete evidence and a fix.
2. **Scoring** (reproducible result) — a **3-category** rubric (9 dimensions) anchored by a **recurring-issue catalog** of fixed detection triggers + severities, followed by a **single consolidation** into root causes and **one batched root-cause attribution** pass for major issues. It turns the findings into **pure-formula 1–5 category scores** so two runs on the same configuration yield the same numbers.
> **Golden rule of scoring:** you only ever **find and label issues** (`major` / `minor`). You do NOT invent the numeric score. The 1–5 numbers come from a **fixed formula** applied to the issue counts (see [Appendix A](#appendix-a--scoring-model)). Same issue set ⇒ same score.
## Site type routing
Before reading or executing the workflow below, perform the existing SPA project lookup first.
- Look for `powerpages.config.json` in the current directory or immediate subdirectories using the
existing file-search patterns.
- If found, continue with the existing SPA workflow below.
- Only when that existing SPA lookup finds no `powerpages.config.json`, run:
```bash
node "${PLUGIN_ROOT}/scripts/lib/detect-project-context.js"
```
- If it returns `siteType: "non-spa"`, read and follow
`${PLUGIN_ROOT}/skills/audit-permissions/references/non-spa-site-workflow.md`.
Do not execute the SPA workflow below.
- Otherwise, continue to Step 1 and preserve its existing not-found behavior.
## Workflow
1. **Verify Site Deployment** — Check that `.powerpages-site` folder and table permissions exist
2. **Gather Configuration** — Read web roles, table permissions, site code, run the shared schema validator, and build the deterministic preflight cross-reference
3. **Analyze & Discover** — Query Dataverse for relationships and lookup columns using deterministic scripts
4. **Run Audit Checks** — Compare permissions against code usage and best practices (A–K checklist)
5. **Score the Configuration** — Detect/label issues by the 3 categories using the recurring-issue catalog, consolidate to distinct root causes (major/minor), compute the 1–5 category scores and the verdict
6. **Root-cause attribution** — In a single batched pass, label every major issue as permissions-only or caused by an upstream artifact, with a one-sentence justification shown in the report
7. **Generate Report** — Create the HTML report (score overview + findings + inventory) and validate it
8. **Present Findings & Track** — Summarize, record skill usage, and ask the user if they want to fix issues
**Important:** Do NOT ask the user questions during analysis. Autonomously gather all data, then present findings.
## Audit completion telemetry
At the very start of Step 1, before site verification, initialize local run state:
```bash
node "${PLUGIN_ROOT}/scripts/emit-audit-permissions-telemetry.js" --action start
```
Parse the JSON stdout and retain its `auditRunId` as `<AUDIT_RUN_ID>` for this invocation. The command does not emit a telemetry event; the existing generic skill invocation event is the start signal. The local run state provides the opaque random ID and start time needed for completion telemetry. Never derive the ID from, or replace it with, a site, environment, tenant, user, path, or report value.
Telemetry is best-effort and must never block the audit. If the initialization command fails or returns no `auditRunId`, continue the audit without completion telemetry. Do not invent an id and do not search local state for the latest run.
On every controlled terminal failure after a run id was returned, close the run before stopping:
```bash
node "${PLUGIN_ROOT}/scripts/emit-audit-permissions-telemetry.js" \
--action complete \
--runId "<AUDIT_RUN_ID>" \
--outcome failure \
--failureStage "<FAILURE_STAGE>"
```
Use exactly one of these fixed failure stages:
- `site_verification`
- `configuration_gathering`
- `schema_validation`
- `relationship_discovery`
- `audit_checks`
- `scoring`
- `root_cause_attribution`
- `report_rendering`
- `report_validation`
- `metrics_validation`
- `unknown_controlled_failure`
Do not pass error messages, paths, table names, finding content, or other user/site data to the telemetry script. A telemetry completion failure does not change the audit outcome and must not trigger a second completion attempt.
## Task Tracking
At the start of Step 1, create all tasks upfront using `TaskCreate`. Mark each task `in_progress` when starting and `completed` when done.
| Task subject | activeForm | Description |
|-------------|------------|-------------|
| Verify site deployment | Verifying site deployment | Check .powerpages-site folder and table permissions exist |
| Gather configuration | Gathering configuration | Read web roles, table permissions, site code; run validator; build preflight |
| Discover relationships | Discovering relationships | Query Dataverse for lookup columns and relationships |
| Run audit checks | Running audit checks | Create per-table tasks and run checklist (A–K) for each table, then cross-validate |
| Score configuration | Scoring configuration | Detect/label by the 3 categories via the recurring-issue catalog, consolidate to root causes, compute 1–5 scores |
| Root-cause attribution | Attributing root causes | Label every major issue permissions-only or upstream-caused in a single pass |
| Generate report | Generating report | Create and validate the HTML report and display it in browser |
| Present findings | Presenting findings | Summarize results, record usage, and offer to fix issues |
**Note:** The "Run audit checks" phase creates **additional per-table tasks** dynamically in Step 4.2. These per-table tasks track the systematic A–K checklist for each table independently.
---
## Step 1: Verify Site Deployment
Use `Glob` to find:
- `**/powerpages.config.json` — identifies the project root
- `**/.powerpages-site/table-permissions/*.tablepermission.yml` — existing permissions
If no `.powerpages-site` folder exists, stop and tell the user to deploy first using `/deploy-site`.
If no table permissions exist, note this as a critical finding (the site may have no data access configured) and continue the audit — there may still be code references that need permissions.
Before stopping because `.powerpages-site` is absent, close completion telemetry with `failureStage: site_verification` as described above.
---
## Step 2: Gather Configuration
### Single-pass performance contract
Gather all local evidence in **one bounded pass** before making judgments:
1. Read web roles, table permissions, site settings, and `.datamodel-manifest.json` in grouped operations.
2. Scan source files once for API operations, entity sets, selects, filters, lookups, expands, uploads, routes, imports, and feature/auth gates. Prefer one grouped search plus targeted reads of only the matching regions; never read an entire source tree file-by-file.
3. Locate the permission plan once. Extract all authorization-relevant statements in one operation into `planClaims`; do not reopen or re-extract the plan later.
4. Freeze these facts in `audit-evidence.json`. Steps 4–6 consume only this ledger plus any gated Dataverse results.
Do not rescan source code or the plan to gain confidence. A second read is allowed only when a specific ledger field is missing and the exact file/region needed is known. Record the added evidence once, then continue. Never perform multiple searches for differently worded versions of the same plan claim.
### 2.1 Read Web Roles
Read all files matching `**/.powerpages-site/web-roles/*.yml`. Keys may carry a publisher prefix — try `mspp_<key>`, then `adx_<key>`, then the bare `<key>` (first found wins). Extract `id`, `name`, `anonymoususersrole`, `authenticatedusersrole` from each. If YAML fails to parse or its root isn't an object, record a **parse error** (feeds preflight `IS`).
### 2.2 Read Table Permissions
Read all files matching `**/.powerpages-site/table-permissions/*.tablepermission.yml`. Using the same prefix rule, for each permission extract:
- `entityname` (permission name)
- `entitylogicalname` (table)
- `scope` (numeric code) → map to a label: `756150000 = Global`, `756150001 = Contact`, `756150002 = Account`, `756150003 = Parent`, `756150004 = Self`; anything else → `Unknown(<code>)`; missing → scope `-1`, label `Unknown`
- `read`, `create`, `write`, `delete`, `append`, `appendto` (boolean flags)
- `adx_entitypermission_webrole` (array of web role UUIDs) → resolve each GUID to a role name via §2.1; unresolved → mark `<unresolved:…>`
- `contactrelationship`, `accountrelationship` (if Contact/Account scope)
- `parententitypermission`, `parentrelationship` (if parent scope)
Record a **parse error** on failure (feeds preflight `IS`).
### 2.3 Analyze Site Code
In the single source pass, search the site source code for:
- Web API calls (`/_api/`)
- Lookup bindings (`@odata.bind`)
- File uploads (`uploadFileColumn`, `uploadFile`, `upload*Photo`, `upload*Image`)
- `$expand` usage (`$expand`, `buildExpandClause`, `ExpandOption`)
Also check for `.datamodel-manifest.json` in the project root for the authoritative table list. It has `{ environmentUrl?, tables: [{ logicalName, displayName, status?, columns: [{ logicalName, type }] }] }`. If missing or `tables` isn't an array, treat the data model as absent.
Additionally scan **Web API artifacts** (used by the root-cause attribution in Step 6 — best-effort):
- **Central client**: present if any of `src/shared/powerPagesApi.ts(x)` or `src/lib/powerPagesApi.ts` exists.
- **Service files** under `src/shared/services/**` (`.ts/.tsx/.js/.jsx`): record which data-model table logical names and which HTTP methods (`GET/POST/PATCH/PUT/DELETE`) appear in each.
- **Wildcard column selects**: record every occurrence of `$select=*` (or a `$select` whose value is `*`) in any scanned source file, together with its file path and the table being queried.
- **Type files** under `src/types/**`: extract property names of the first `interface`/`type` literal; infer the table from filename/content when possible.
- **Web API site settings** in `.powerpages-site/site-settings/` (files named `Webapi-*` / `Webapi/*`): parse `name` + `value`. Split `name` on `/`: `Webapi/<entitySet>/enabled` → kind `enabled`; `.../fields` → kind `fields`; `Webapi/error` → `error`; else `other`. `webapiEnabledEntitySets` = entity sets whose `enabled` value is exactly `"true"`. For every `fields` setting also record **`isWildcard`** — true when the trimmed value is `*`, or when any comma-separated entry is `*`. A list that names column logical names is NOT a wildcard, however long it is.
Also scan **authentication/registration site settings** in `.powerpages-site/site-settings/` regardless of filename. Parse `name` + `value` for settings under `Authentication/Registration/`, including `Enabled`, `OpenRegistrationEnabled`, `ExternalLoginEnabled`, and `InvitationEnabled`. Also parse each external provider's `Authentication/<Type>/<Provider>/RegistrationEnabled`; a configured provider (any settings under `Authentication/<Type>/<Provider>/`) without that setting counts as `true`, the server default. Compare names case-insensitively and treat a value as enabled only when its trimmed value is case-insensitively `"true"`. Record missing settings as `unknown`, not `false`.
Build an **audience reachability profile** before judging permissions:
- A role with `authenticatedusersrole: true` is automatically assigned to every signed-in site user; it is a broad baseline role, not proof of staff, employee, teacher, parent, or other trusted-persona membership.
- **Open registration** is proven when `OpenRegistrationEnabled` is `true` and either local registration is on (`Authentication/Registration/Enabled` is `true`) or `ExternalLoginEnabled` is not `false` (missing counts as `true`, the server default) and at least one configured external provider's `RegistrationEnabled` is `true`. External-only sites often omit `Authentication/Registration/Enabled`. With open registration, any visitor can create an account and enter that broad Authenticated Users audience.
- External login or invitation enablement may provide additional entry paths, but do not assume they are open to the public without supporting configuration evidence.
- Carry this profile into every per-table scope and audience check. Do not evaluate a role name or permission in isolation from how users acquire that role.
Build a map of: which tables are referenced in code, which CRUD operations are performed on each, which lookup relationships are used, and which related tables are fetched via `$expand` (these need read permissions too).
Also build a **capability matrix** before judging missing access. One row per authorization-relevant capability:
`persona | route/component | reachability | table | operation | current grant | plan claim | evidence`
Classify `reachability` mechanically:
- `reachable` — the page/component is registered in the deployed router or invoked by another reachable component, and no explicit feature flag or authorization gate disables it for that persona.
- `disabled` — an explicit false feature flag, server-side authorization gate, build exclusion, or unreachable/unregistered component prevents the capability from running.
- `ambiguous` — code exists but neither reachability nor exclusion can be established.
A UI condition based on the signed-in user's own data (for example an `isAccountAdmin` field or a role flag on their profile record) never makes a capability `disabled` — it identifies the persona that uses it. Plan or comment wording such as "deferred", "future phase" or "not yet supported" never makes a routed capability `disabled` or `ambiguous`.
Use this evidence precedence everywhere in the audit: **reachable implementation > explicit runtime gate/build exclusion > implementation plan > comments/names**. A plan cannot make a routed, callable feature hypothetical merely by calling its persona "back-office." Conversely, dead, unregistered, explicitly disabled, or server-gated code does not establish a required portal permission. If reachability is ambiguous and conflicts with the plan, emit at most one **minor** `internal-consistency` issue for the conflict; do not presume a broken flow.
After the source pass, do not reopen routes, pages, services, or the permission plan during scoring. Reachability and plan claims are frozen ledger facts, not questions to reconsider in Step 5.
### 2.4 Run Shared Schema Validator
Run the shared validator against the existing site:
```bash
node "${PLUGIN_ROOT}/scripts/validate-permissions-schema.js" --projectRoot "<PROJECT_ROOT>"
```
Parse the JSON output and carry the findings into the audit as **major/minor** issues. Map:
- `error` findings → **major** issue
- `warning` findings → **major** issue (unless purely forward-looking/cosmetic → **minor**)
- `info` findings → **minor** issue
These findings should be included in the final report even if the later code/Dataverse analysis also finds additional issues. Exception: drop the validator's "no associated web roles" warning for a Parent-scope child permission whose parent chain is valid (see check B).
If the validator reports wildcard field access in a `Webapi/<table>/fields` setting, add this finding as a **major** `security-posture` issue (one per affected setting):
- **Title:** `Unsupported wildcard Web API fields for <table>`
- **Reasoning:** The fields setting uses wildcard access, which is unsupported beginning September 14, 2026
- **Fix:** Replace the wildcard using `${PLUGIN_ROOT}/references/webapi-field-allowlist.md`: LogicalNames for ordinary columns, `_<LogicalName>_value` for lookup reads, and exact Navigation Properties used by `@odata.bind`
- **Details:** Include the site-setting file path and setting name from the validator finding
After Step 3.1 determines the environment URL, rerun the shared validator with live relationship verification only when the Step 3 discovery gate is open. Merge any additional findings:
```bash
node "${PLUGIN_ROOT}/scripts/validate-permissions-schema.js" --projectRoot "<PROJECT_ROOT>" --validate-dataverse-relationships --envUrl "<envUrl>"
```
Use this Dataverse-backed relationship validation only for local runs that need relationship evidence. Do **not** require it in CI or other offline contexts, and do not run it for Global-only/read-only designs with no relationship-dependent reachable flow.
### 2.5 Deterministic preflight cross-reference (grader ground truth)
Purely mechanical cross-checks over the parsed YAML + data model + Web API artifacts. **Emit ALL that apply.** Number IDs per prefix in encounter order (`IS1`, `IS2`, `DM1`, …). These are **ground truth**: carry them into the right dimension's issue list in Step 5 and never drop or downgrade them.
| Condition | id prefix | dimension | severity |
|---|---|---|---|
| Web-role YAML parse error | IS | internal-consistency | major |
| Table-permission YAML parse error | IS | internal-consistency | major |
| Permission references a web-role GUID not defined in any role | IS | internal-consistency | major |
| Web role has a **blank id** | IS | internal-consistency | major |
| Permission has a **blank `entitylogicalname`** | DM | data-model-alignment | major |
| Permission grants **no privileges** (all 6 CRUD bits false) | TC | table-coverage | major |
| Permission has **no scope** (`scope < 0`) | SC | scope-correctness | major |
| Permission scope code **unrecognized** (`Unknown(code)`) | SC | scope-correctness | minor |
| Permission grants **write/create/delete to an Anonymous role** | AH | anonymous-access-hygiene | major |
| Permission targets a table **not in the data model** (only when a valid data-model manifest exists) | DM | data-model-alignment | major |
| Web API site-setting YAML parse error | IS | internal-consistency | major |
| `-enabled` entity set with **no matching `-fields`** whitelist | IS | internal-consistency | major |
| `-fields` whitelist with **no matching `-enabled`** setting | IS | internal-consistency | major |
| Type file declaring 1–6 properties absent from the data model (only when a valid data-model manifest exists) | DM | data-model-alignment | minor |
---
### 2.6 Freeze the Evidence Ledger
`<OUTPUT_DIR>` is `<PROJECT_ROOT>/docs/` when working in a website (a project root with `powerpages.config.json`); otherwise it is the system temp directory. The temporary files and the final report all go there.
Before running judgment-based checks, write a temporary `<OUTPUT_DIR>/audit-evidence.json` containing the normalized facts gathered so far: roles, permissions, data-model tables/columns, service operations, route/component reachability, capability matrix, lookup/expand usage, client-side row filters, implementation-plan claims, authentication reachability, and preflight issues. Sort tables, permissions, routes, and capabilities by stable identifiers.
Steps 4–6 MUST reason from this ledger instead of rescanning and selectively rediscovering evidence. If live Dataverse discovery adds facts in Step 3, append those facts and rewrite the ledger once before Step 4. Do not change a `reachability` classification during scoring unless new evidence is added to the ledger. Delete `audit-evidence.json` after the final HTML report passes validation.
---
## Step 3: Analyze & Discover (Dataverse API)
Use deterministic Node.js scripts for all Dataverse API calls. These scripts handle auth token acquisition, HTTP requests, and JSON parsing consistently.
### Dataverse discovery gate
Before calling `pac env who` or any Dataverse query script, compute `needsLiveDiscovery`. It is `true` only when at least one reachable capability has one of these unresolved dependencies:
- Contact, Account, or Parent scope whose relationship name must be verified
- create/write code that binds or changes a lookup
- `$expand` or related-table access whose target cannot be resolved from local metadata
- file/image upload whose relationship or target metadata is unresolved
It is `false` when none of those dependencies apply — for example, Global-only/read-only flows, explicit Administrator-only CRUD unused by reachable site code, and cases fully resolved by the manifest and local source. When `false`, skip all of Step 3, record `liveDiscovery: "not-needed"` in the evidence ledger, and continue to Step 4. When `true`, first confirm the active Dataverse environment URL matches the manifest environment URL; if it does not, skip live queries and record the mismatch instead of querying the wrong environment.
### 3.1 Get Environment URL
```bash
pac env who
```
Extract the `Environment URL` (e.g., `https://org12345.crm.dynamics.com`) and use it as `<envUrl>` in subsequent script calls.
### 3.2 Query Lookup Columns
For each table that has permissions with `create` or `write` enabled, use the lookup query script:
```bash
node "${PLUGIN_ROOT}/skills/audit-permissions/scripts/query-table-lookups.js" --envUrl "<envUrl>" --table "<table_logical_name>"
```
The script returns a JSON array of `{ logicalName, targets }` for each lookup column. Capture this output for the maps described below.
After querying **all** tables with create or write permissions, build two maps from the combined results:
1. **Source map** (table → lookup columns): For each queried table, record which lookup columns it has and their targets. Used in Section H2 to check `appendto` on the source table.
2. **Reverse target map** (target table → list of source tables): For each target table found in any lookup's `targets` array, record which source table(s) reference it. Used in Section H to check `append` on the target table.
Example: querying `order_item` returns `[{ logicalName: "cr4fc_orderid", targets: ["cr4fc_order"] }]`
- Source map: `order_item → [{ column: "cr4fc_orderid", targets: ["cr4fc_order"] }]`
- Reverse target map: `cr4fc_order → [{ sourceTable: "order_item", column: "cr4fc_orderid" }]`
Both maps are used in Sections H and H2:
- The **source table** (with the lookup) needs `appendto: true` — it links TO other records (checked via the source map)
- Each **target table** in `targets` needs `append: true` — other records link TO it (checked via the reverse target map)
### 3.3 Query Relationships
For tables with parent-scope permissions, verify the relationship names using the relationship query script:
```bash
node "${PLUGIN_ROOT}/skills/audit-permissions/scripts/query-table-relationships.js" --envUrl "<envUrl>" --table "<parent_table>"
```
The script returns a JSON array of `{ schemaName, referencedEntity, referencingEntity, referencingAttribute }`. Use `schemaName` to validate the `parentrelationship` value in parent-scope permissions.
### Error Handling
If any script exits with code 1, skip the API-dependent checks and note which checks were skipped in the report. Do NOT stop the entire audit for auth errors. Use the data model manifest and code analysis as fallback.
---
## Step 4: Run Audit Checks
Use per-table task tracking to systematically run every audit check. **These code- and Dataverse-grounded checks are the primary issue detectors** — they catch concrete problems (missing CRUD, append/appendto, `$expand` gaps, broken parent chains, over-provisioned grants) that rubric judgment alone would miss, which is what makes the issue set richer and the score more faithful. Each failed check emits **one provisional candidate** (title, responsible table, evidence, and a suggested fix); Step 5 assigns its final **major**/**minor** severity and dimension. A check that passes produces **no candidate**. Where a check says to search the service code, look the fact up in the evidence ledger (Step 2.6); search the source only when the ledger lacks it.
### 4.1 Build Audit Inventory
First, build a combined list of all tables to audit from two sources:
1. **Tables referenced in code** (from Step 2.3) — these may or may not have permissions
2. **Tables with existing permissions** (from Step 2.2) — these may or may not be referenced in code
The union of these two sets is the complete audit scope. Each table will be audited from both directions: "does the code need a permission that doesn't exist?" and "does the permission match what the code actually does?"
### 4.2 Create Per-Table Audit Tasks
For each table in the audit inventory, create a task:
```
TaskCreate:
subject: "Audit <table_logical_name>"
activeForm: "Auditing <table_display_name> permissions"
description: "Run all audit checks for <table_logical_name>"
```
Also create a summary task:
```
TaskCreate:
subject: "Compile audit findings"
activeForm: "Compiling audit findings"
description: "Combine all per-table findings into the final report"
```
Use `TaskList` at any point to review progress and see which tables still need auditing.
### 4.3 Per-Table Audit Checklist
For each table, mark its task `in_progress` and run through the following checks **in order**. For every issue, note the **specific evidence** (file path, permission name, code pattern) that supports it. Skip checks that don't apply to this table.
**Do not finalize severity or dimension in Step 4.** Each check below carries a provisional audit tier (`critical`, `warning`, or `info`) and emits a factual candidate as `{ sourceId, auditTier, title, table, reasoning, fix, evidence, reachability? }`. A check that passes yields no candidate. Step 5 is the **only** place that assigns the final `major|minor` severity and canonical dimension, using fixed catalog rules before generic policy. This prevents whichever audit path runs first from locking in a different score.
**A. Permission Existence**
Does this table have a table permission?
- If the table is referenced in code but has **no permission** → finding:
- **Severity:** `critical`
- **Title:** `Missing permission for <table>`
- **Reasoning:** Which code files reference this table and what operations they perform
- **Fix:** Create a permission with the appropriate scope and CRUD flags
- If a permission exists but the table is **not referenced in code** → finding:
- **Severity:** `info`
- **Title:** `Unused permission for <table>`
- **Reasoning:** The table is not referenced in any source code — the permission may be unnecessary
- **Fix:** Review whether this permission is still needed
- If both exist → `pass`, proceed to remaining checks
**B. Web Role Association**
Does the permission have web role(s) assigned?
- Check `adx_entitypermission_webrole` — if empty or missing → finding:
- **Severity:** `warning`
- **Title:** `Permission <name> has no web role association`
- **Reasoning:** A permission without a web role has no effect — no users will receive this access
- **Fix:** Associate with the appropriate web role
- Exception: a Parent-scope (`756150003`) child permission may leave its roles empty — it inherits role association through the parent chain. Raise no finding when its `parententitypermission` resolves to an existing permission; a broken chain is reported by check I.
- If roles are assigned → `pass`
**C. Scope Appropriateness**
Is the scope the least-privileged option that fits?
- Search the service code for scope-relevant patterns: contact-scoped filters (`getCurrentContactId`, `_contactid_value`, `contactid`) and account-scoped filters (`_accountid_value`, `parentcustomerid`)
- For EACH Global-read permission, resolve every assigned role and apply the Step 2.3 audience reachability profile. Then inspect the table's selected/whitelisted columns, data-model columns, UI purpose, and implementation plan to determine whether the data is explicitly public or intended for a narrower persona.
- **Mandatory cross-artifact trigger, evaluated separately per affected table:** emit a finding when ALL four conditions hold: (1) open registration is proven (Step 2.3 audience reachability profile); (2) the assigned web role has `authenticatedusersrole: true`, so every registered account receives it; (3) that role is attached to this table's permission with `read: true` and G...
© Microsoft · MIT · microsoft/power-platform-skills