|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | + Validates that custom Sensitive Information Types (SITs) are configured in the organization. |
| 4 | +
|
| 5 | +.DESCRIPTION |
| 6 | + This test checks if custom Sensitive Information Types are configured, enabling detection of |
| 7 | + organization-specific sensitive data patterns beyond the built-in SIT library. Custom SITs are |
| 8 | + critical for protecting proprietary data formats and industry-specific information. |
| 9 | +
|
| 10 | +.NOTES |
| 11 | + Test ID: 35033 |
| 12 | + Category: Advanced Classification |
| 13 | + Pillar: Data |
| 14 | + Required Module: ExchangeOnlineManagement |
| 15 | + Required Connection: Security & Compliance PowerShell |
| 16 | +#> |
| 17 | + |
| 18 | +function Test-Assessment-35033 { |
| 19 | + [ZtTest( |
| 20 | + Category = 'Advanced Classification', |
| 21 | + ImplementationCost = 'High', |
| 22 | + MinimumLicense = ('Microsoft 365 E5 Compliance'), |
| 23 | + Pillar = 'Data', |
| 24 | + RiskLevel = 'High', |
| 25 | + SfiPillar = 'Protect tenants and production systems', |
| 26 | + TenantType = ('Workforce'), |
| 27 | + TestId = 35033, |
| 28 | + Title = 'Custom Sensitive Information Types (SITs) Configured', |
| 29 | + UserImpact = 'Medium' |
| 30 | + )] |
| 31 | + [CmdletBinding()] |
| 32 | + param() |
| 33 | + |
| 34 | + #region Data Collection |
| 35 | + Write-PSFMessage '🟦 Start' -Tag Test -Level VeryVerbose |
| 36 | + |
| 37 | + $activity = 'Checking Custom Sensitive Information Types Configuration' |
| 38 | + Write-ZtProgress -Activity $activity -Status 'Getting custom SIT configuration' |
| 39 | + |
| 40 | + # Get all custom Sensitive Information Types |
| 41 | + $customSITs = $null |
| 42 | + $errorMsg = $null |
| 43 | + |
| 44 | + try { |
| 45 | + $allSITs = Get-DlpSensitiveInformationType -ErrorAction Stop |
| 46 | + # Filter for custom SITs (Publisher is not "Microsoft Corporation") |
| 47 | + $customSITs = @($allSITs | Where-Object { $_.Publisher -ne 'Microsoft Corporation' }) |
| 48 | + } |
| 49 | + catch { |
| 50 | + $errorMsg = $_ |
| 51 | + Write-PSFMessage "Failed to retrieve custom SIT configuration: $_" -Tag Test -Level Warning |
| 52 | + } |
| 53 | + #endregion Data Collection |
| 54 | + |
| 55 | + #region Assessment Logic |
| 56 | + $passed = $false |
| 57 | + $customStatus = $null |
| 58 | + |
| 59 | + if ($errorMsg) { |
| 60 | + # Investigate: Cannot query custom SITs |
| 61 | + $passed = $false |
| 62 | + $customStatus = 'Investigate' |
| 63 | + } |
| 64 | + elseif ($null -eq $customSITs) { |
| 65 | + # Investigate: Cannot determine custom SIT status |
| 66 | + $passed = $false |
| 67 | + $customStatus = 'Investigate' |
| 68 | + } |
| 69 | + elseif ($customSITs.Count -ge 1) { |
| 70 | + # Pass: Custom SITs are configured |
| 71 | + $passed = $true |
| 72 | + } |
| 73 | + else { |
| 74 | + # Fail: No custom SITs configured |
| 75 | + $passed = $false |
| 76 | + } |
| 77 | + #endregion Assessment Logic |
| 78 | + |
| 79 | + #region Report Generation |
| 80 | + $testResultMarkdown = '' |
| 81 | + |
| 82 | + if ($customStatus -eq 'Investigate') { |
| 83 | + $testResultMarkdown = "### Investigate`n`n" |
| 84 | + $testResultMarkdown += "Unable to determine custom SIT status due to permissions issues or service connection failure." |
| 85 | + } |
| 86 | + elseif ($passed) { |
| 87 | + $testResultMarkdown = "✅ Custom Sensitive Information Types are configured, enabling detection of organization-specific sensitive data patterns.`n`n" |
| 88 | + } |
| 89 | + else { |
| 90 | + $testResultMarkdown = "❌ No custom Sensitive Information Types are configured; relying solely on built-in SIT patterns.`n`n" |
| 91 | + } |
| 92 | + |
| 93 | + # Build detailed information if we have data |
| 94 | + if ($customSITs -and $customSITs.Count -gt 0) { |
| 95 | + $testResultMarkdown += "## [Custom Sensitive Information Types](https://purview.microsoft.com/informationprotection/dataclassification/sensinfoTypes)`n`n" |
| 96 | + $testResultMarkdown += "| Name | Description | Publisher |`n" |
| 97 | + $testResultMarkdown += "| :--- | :--- | :--- |`n" |
| 98 | + |
| 99 | + foreach ($sit in $customSITs | Sort-Object Name) { |
| 100 | + $safeSITName = Get-SafeMarkdown $sit.Name |
| 101 | + $safeDescription = if ($sit.Description) { Get-SafeMarkdown $sit.Description } else { 'Not specified' } |
| 102 | + $safePublisher = if ($sit.Publisher) { Get-SafeMarkdown $sit.Publisher } else { 'Not specified' } |
| 103 | + |
| 104 | + $testResultMarkdown += "| $safeSITName | $safeDescription | $safePublisher |`n" |
| 105 | + } |
| 106 | + |
| 107 | + $testResultMarkdown += "`n**Summary:**`n" |
| 108 | + $testResultMarkdown += "* Total Custom SITs: $($customSITs.Count)`n" |
| 109 | + } |
| 110 | + #endregion Report Generation |
| 111 | + |
| 112 | + $params = @{ |
| 113 | + TestId = '35033' |
| 114 | + Title = 'Custom Sensitive Information Types (SITs) Configured' |
| 115 | + Status = $passed |
| 116 | + Result = $testResultMarkdown |
| 117 | + } |
| 118 | + if ($customStatus) { |
| 119 | + $params.CustomStatus = $customStatus |
| 120 | + } |
| 121 | + Add-ZtTestResultDetail @params |
| 122 | +} |
0 commit comments