Skip to content

fix: Invoke-InforcerAssessment no longer scores unassessed checks as failures - #46

Merged
royklo merged 2 commits into
mainfrom
fix/assessment-not-assessed-status
Oct 22, 2026
Merged

royklo merged 2 commits into
mainfrom
fix/assessment-not-assessed-status

Conversation

@royklo

@royklo royklo commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Summary of changes

The 2026-09-29 OpenAPI refresh (#45) added findings.status (pass, fail, insufficientPermissions, error). The last two mean the check was never assessed, but they still carry compliant: false. Invoke-InforcerAssessment only read compliant, so these checks came out as Fail, showed as Non-Compliant in the HTML report and lowered the score. Copilot flagged this on #45 (comment).

Confirmed live: CIS M365 L1 + L2 on tenant 14436 returned two PIM approval checks as status: "error" ("data could not be read from the tenant"). The module reported 73.1% (79/108); the correct figure is 74.5% (79/106, 2 not assessed).

  • Status follows findings.status: Pass, Fail, InsufficientPermissions or Error. When the API sends no status, compliant decides as before.
  • One $summarize block replaces the two duplicated score calculations (single-tenant and multi-tenant). The score is Pass ÷ (Pass + Fail).
  • Multi-tenant -OutputType JsonObject gains NotAssessed. That is a new output property, so this is 0.8.0.
  • Both HTML reports show unassessed checks in grey as Not Assessed, with their own count and filter, a ? cell in the matrix, and an em dash for a category where nothing was assessed. The matrix's "All Passed" filter no longer includes rows where a tenant was not assessed.
  • CHANGELOG and CMDLET-REFERENCE are updated.

Related issue

None. Follow-up to the review comment on #45.

Checklist

  • Tests pass locally: 475 passed, 0 failed, 2 skipped (471 before, plus 4 new). The new tests run the real cmdlet with mocked API calls, and they fail when the insufficientPermissions/error mapping is removed.
  • Comment-based help updated (.DESCRIPTION lists the Status values)
  • Consistency contract followed (no parameter changes, JSON depth 100)
  • docs/CMDLET-REFERENCE.md updated
  • PSScriptAnalyzer: same findings as main, nothing new.

🤖 Generated with Claude Code

…failures

The 2026-09-29 OpenAPI refresh (#45) added findings.status: pass, fail,
insufficientPermissions or error. The last two mean the check never ran, yet
they carry compliant=false, and the cmdlet derived Status from compliant
alone. Unassessed checks became Fail, rendered as Non-Compliant and lowered
the score. Copilot flagged it on the merged PR.

Confirmed live on tenant 14436 (CIS M365 L1+L2): two PIM approval checks came
back as status=error with "data could not be read from the tenant", turning
79/106 (74.5%) into 79/108 (73.1%).

Status now follows findings.status (falling back to compliant when absent).
One $summarize block replaces the two duplicated score calculations and scores
Pass / (Pass + Fail). Multi-tenant JSON gains NotAssessed, hence 0.8.0. Both
HTML reports render the state neutrally: badge, filter, a "?" matrix cell, and
an em dash for a category with nothing assessed. The matrix "All Passed"
filter no longer counts a not-assessed row as passed.

Four tests go through the real cmdlet with mocked API calls; removing the
insufficientPermissions/error mapping fails them. 475/0/2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 18:32

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.

🟡 Changes recommended

The matrix report still lacks the dedicated Not Assessed filter promised in the PR description and changelog.

1 open issue
What changed in this PR

Corrects assessment scoring so checks the API could not assess are reported separately rather than counted as failures.

Changes:

  • Maps API statuses and shares score calculation across single-tenant and multi-tenant runs.
  • Adds neutral HTML presentation and a multi-tenant JSON NotAssessed count.
  • Adds regression tests, updates documentation, and bumps the module to 0.8.0.
File Description
Tests/​Consistency.Tests.ps1 Adds status, scoring, and HTML regression tests.
module/​Public/​Invoke-InforcerAssessment.ps1 Maps statuses and excludes unassessed checks from scoring.
module/​Private/​ConvertTo-InforcerAssessmentMatrixHtml.ps1 Displays unassessed cells and counts; adjusts All Passed filtering.
module/​Private/​ConvertTo-InforcerAssessmentHtml.ps1 Adds neutral badges, filtering, and assessed-only category scores.
module/​InforcerCommunity.psd1 Bumps the version to 0.8.0.
docs/​CMDLET-REFERENCE.md Documents statuses and scoring behavior.
CHANGELOG.md Records the fix, output addition, and migration guidance.

Review effort: Balanced

The single-tenant report got a Not Assessed filter but the matrix did not,
although the changelog says both reports have one. A row whose only
non-pass cell is "?" was hidden under both Has Failures and All Passed,
so it was reachable only through All. Flagged by Copilot on #46.

The button appears only when a tenant has unassessed checks and selects
rows with a "?" in a displayed tenant column. Verified by clicking every
filter in headless Chromium against a rendered report; the test also
asserts the button is absent when nothing is unassessed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 18:40

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.

🟢 Approval recommended

Status handling, assessed-only scoring, report integration, and regression coverage are consistent, with no unresolved blocking issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@royklo
royklo merged commit beaac22 into main Oct 22, 2026
4 checks passed
@royklo
royklo deleted the fix/assessment-not-assessed-status branch October 22, 2026 18:43
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.

2 participants