Skip to content

Conversation

@alexandair
Copy link
Collaborator

Copilot AI review requested due to automatic review settings December 22, 2025 22:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new test (ID 35003) to check for the presence and configuration of sensitivity labels in Microsoft tenants. Sensitivity labels are foundational to Microsoft Information Protection and help organizations classify and protect sensitive data.

Key Changes

  • New test function that queries sensitivity labels via the Get-Label cmdlet and validates that at least one label is configured
  • Comprehensive reporting that includes label statistics (total, top-level, and sub-labels) and a sample table of up to 5 labels
  • Unit tests covering success, failure, and error handling scenarios

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/powershell/tests/Test-Assessment.35003.ps1 Main test implementation that checks for configured sensitivity labels with error handling and detailed markdown report generation
src/powershell/tests/Test-Assessment.35003.md Documentation providing context about sensitivity labels, remediation steps, and reference links
code-tests/test-assessments/Test-Assessment.35003.Tests.ps1 Comprehensive unit tests covering scenarios with labels, no labels, and error conditions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +88 to +92
$parentName = if (-not [string]::IsNullOrEmpty($label.ParentLabelDisplayName)) { $label.ParentLabelDisplayName } else { "None" }
$labelName = Get-SafeMarkdown -Text $label.DisplayName
$parentName = Get-SafeMarkdown -Text $parentName
$testResultMarkdown += "| $labelName | $($label.Priority) | $parentName |`n"
}
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable $parentName is being reassigned after it's already set. On line 88, $parentName is assigned a value from the label property or "None", then on line 90 it's reassigned with the result of Get-SafeMarkdown. This should be done in a single step to avoid the unnecessary reassignment and potential confusion. Consider combining these operations or using a different variable name for the sanitized version.

Suggested change
$parentName = if (-not [string]::IsNullOrEmpty($label.ParentLabelDisplayName)) { $label.ParentLabelDisplayName } else { "None" }
$labelName = Get-SafeMarkdown -Text $label.DisplayName
$parentName = Get-SafeMarkdown -Text $parentName
$testResultMarkdown += "| $labelName | $($label.Priority) | $parentName |`n"
}
$parentName = Get-SafeMarkdown -Text (if (-not [string]::IsNullOrEmpty($label.ParentLabelDisplayName)) { $label.ParentLabelDisplayName } else { "None" })
$labelName = Get-SafeMarkdown -Text $label.DisplayName
$testResultMarkdown += "| $labelName | $($label.Priority) | $parentName |`n"
}

Copilot uses AI. Check for mistakes.
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