diff --git a/powershell/internal/checks/cis/fabric/Test-MtCisFabricTenantSetting.ps1 b/powershell/internal/checks/cis/fabric/Test-MtCisFabricTenantSetting.ps1 index 45b60712c0..b1a9eb46e0 100644 --- a/powershell/internal/checks/cis/fabric/Test-MtCisFabricTenantSetting.ps1 +++ b/powershell/internal/checks/cis/fabric/Test-MtCisFabricTenantSetting.ps1 @@ -1,15 +1,10 @@ function Test-MtCisFabricTenantSetting { <# .SYNOPSIS - Evaluates a Microsoft Fabric tenant setting for a CIS check. + Preserves the CIS entry point for the shared Fabric tenant-setting evaluator. .DESCRIPTION - Reads one validated tenant setting, applies its audit rule, records the observed state, and returns a Boolean result. - - .EXAMPLE - Test-MtCisFabricTenantSetting -SettingName 'ElevatedGuestsTenant' -SettingTitle 'Guest users can browse Fabric content' -Rule DisabledOrGroups - - Returns true when guest browsing is disabled or limited to one or more security groups. + Delegates to the service-neutral evaluator without changing existing CIS audit rules or results. #> [CmdletBinding()] [OutputType([bool])] @@ -27,98 +22,5 @@ [string] $Rule ) - $settings = @(Get-MtFabricTenantSettings | Where-Object { $_.settingName -eq $SettingName }) - if ($settings.Count -ne 1) { - throw "Expected exactly one Fabric tenant setting named '$SettingName'; received $($settings.Count)." - } - - $setting = $settings[0] - if ($setting.enabled -isnot [bool]) { - throw "Fabric tenant setting '$SettingName' did not include a Boolean enabled value." - } - - $isEnabled = $setting.enabled -eq $true - $isDisabled = -not $isEnabled - $groupProperty = $setting.PSObject.Properties['enabledSecurityGroups'] - $enabledGroups = if ($null -eq $groupProperty) { @() } else { @($groupProperty.Value | Where-Object { $_ }) } - $hasGroups = $enabledGroups.Count -gt 0 - $scope = if ($isDisabled) { 'Not applicable' } elseif ($hasGroups) { "$($enabledGroups.Count) security group(s)" } else { 'Entire organization' } - $additionalCondition = 'Not applicable' - $createP2wIsBoolean = $false - $createP2wIsDisabled = $false - - if ($Rule -eq 'PublishToWeb' -and $isEnabled) { - $propertiesProperty = $setting.PSObject.Properties['properties'] - $createP2wProperties = if ($null -eq $propertiesProperty -or $null -eq $propertiesProperty.Value) { - @() - } - else { - @($propertiesProperty.Value | Where-Object { $_.name -eq 'CreateP2w' }) - } - - $createP2wValue = if ($createP2wProperties.Count -eq 1) { $createP2wProperties[0].value } else { $null } - $parsedCreateP2wValue = $false - $createP2wIsBoolean = $createP2wValue -is [string] -and [bool]::TryParse($createP2wValue, [ref] $parsedCreateP2wValue) - $createP2wIsDisabled = $createP2wIsBoolean -and -not $parsedCreateP2wValue - $additionalCondition = if (-not $createP2wIsBoolean) { - 'Not found or invalid' - } - elseif ($createP2wIsDisabled) { - 'Existing codes only' - } - else { - 'New codes allowed' - } - } - - switch ($Rule) { - 'DisabledOrGroups' { - $testResult = $isDisabled -or ($isEnabled -and $hasGroups) - } - 'PublishToWeb' { - $testResult = $isDisabled -or ($isEnabled -and $hasGroups -and $createP2wIsDisabled) - } - 'Disabled' { - $testResult = $isDisabled - } - 'Enabled' { - $testResult = $isEnabled - } - } - - $stateText = if ($isDisabled) { 'disabled' } elseif ($hasGroups) { "enabled for $($enabledGroups.Count) security group(s)" } else { 'enabled for the entire organization' } - if ($Rule -eq 'PublishToWeb' -and $testResult -and $isEnabled) { - $stateText += ' with only existing embed codes allowed' - } - - $resultText = if ($testResult) { 'Pass' } else { 'Fail' } - $enabledText = if ($isEnabled) { 'True' } else { 'False' } - $resultMd = "| Setting | Enabled | Scope | Additional condition | Result |`n" - $resultMd += "| --- | --- | --- | --- | --- |`n" - $resultMd += "| $SettingTitle | $enabledText | $scope | $additionalCondition | $resultText |`n" - - if ($testResult) { - $resultMessage = "Well done. $SettingTitle is $stateText." - } - else { - $resultMessage = switch ($Rule) { - 'DisabledOrGroups' { "$SettingTitle is enabled for the entire organization. Disable it or restrict it to one or more security groups." } - 'PublishToWeb' { - $restrictionsToFix = @() - if (-not $hasGroups) { $restrictionsToFix += 'restrict it to one or more security groups' } - if (-not $createP2wIsBoolean) { - $restrictionsToFix += 'confirm that new embed codes are disabled' - } - elseif (-not $createP2wIsDisabled) { - $restrictionsToFix += 'allow only existing embed codes' - } - "$SettingTitle does not meet the required restrictions. Set it to " + ($restrictionsToFix -join ' and ') + '.' - } - 'Disabled' { "$SettingTitle is enabled. Disable it in Fabric tenant settings." } - 'Enabled' { "$SettingTitle is disabled. Enable it in Fabric tenant settings." } - } - } - - Add-MtTestResultDetail -Result "$resultMessage`n`n$resultMd" - return [bool] $testResult + return Test-MtFabricTenantSetting -SettingName $SettingName -SettingTitle $SettingTitle -Rule $Rule } diff --git a/powershell/internal/services/fabric/Get-MtFabricTenantSettings.ps1 b/powershell/internal/services/fabric/Get-MtFabricTenantSettings.ps1 index 010035e9f4..a55ad39a0c 100644 --- a/powershell/internal/services/fabric/Get-MtFabricTenantSettings.ps1 +++ b/powershell/internal/services/fabric/Get-MtFabricTenantSettings.ps1 @@ -15,12 +15,24 @@ return $__MtSession.FabricCache['TenantSettings'] } - $accessToken = Get-AzAccessToken -ResourceUrl 'https://api.fabric.microsoft.com' -AsSecureString -ErrorAction Stop + $context = Get-AzContext + if ($null -eq $context -or $null -eq $context.Environment -or [string]::IsNullOrWhiteSpace($context.Environment.Name)) { + throw 'The connected Azure context did not identify an Azure environment.' + } + + $environmentName = $context.Environment.Name + $apiEndpoint = switch ($environmentName) { + 'AzureCloud' { 'https://api.fabric.microsoft.com' } + 'AzureUSGovernment' { 'https://highapi.fabric.microsoft.us' } + default { throw "Microsoft Fabric tenant settings are not supported in Azure environment '$environmentName'." } + } + + $accessToken = Get-AzAccessToken -ResourceUrl $apiEndpoint -AsSecureString -ErrorAction Stop if (-not $accessToken.Token) { throw 'The connected Azure context did not return a Microsoft Fabric access token.' } - $requestUri = 'https://api.fabric.microsoft.com/v1/admin/tenantsettings' + $requestUri = "$apiEndpoint/v1/admin/tenantsettings" $settings = [System.Collections.Generic.List[object]]::new() while (-not [string]::IsNullOrEmpty($requestUri)) { $response = Invoke-RestMethod -Method Get ` diff --git a/powershell/internal/services/fabric/Test-MtFabricTenantSetting.ps1 b/powershell/internal/services/fabric/Test-MtFabricTenantSetting.ps1 new file mode 100644 index 0000000000..ea8e8f36f9 --- /dev/null +++ b/powershell/internal/services/fabric/Test-MtFabricTenantSetting.ps1 @@ -0,0 +1,124 @@ +function Test-MtFabricTenantSetting { + <# + .SYNOPSIS + Evaluates a Microsoft Fabric tenant setting using a benchmark audit rule. + + .DESCRIPTION + Reads one validated tenant setting, applies its audit rule, records the observed state, and returns a Boolean result. + + .EXAMPLE + Test-MtFabricTenantSetting -SettingName 'ElevatedGuestsTenant' -SettingTitle 'Guest users can browse Fabric content' -Rule DisabledOrGroups + + Returns true when guest browsing is disabled or limited to one or more security groups. + #> + [CmdletBinding()] + [OutputType([bool])] + param ( + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string] $SettingName, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string] $SettingTitle, + + [Parameter(Mandatory)] + [ValidateSet('DisabledOrGroups', 'PublishToWeb', 'Disabled', 'Enabled')] + [string] $Rule + ) + + $settings = @(Get-MtFabricTenantSettings | Where-Object { $_.settingName -eq $SettingName }) + if ($settings.Count -ne 1) { + throw "Expected exactly one Fabric tenant setting named '$SettingName'; received $($settings.Count)." + } + + $setting = $settings[0] + if ($setting.enabled -isnot [bool]) { + throw "Fabric tenant setting '$SettingName' did not include a Boolean enabled value." + } + + $isEnabled = $setting.enabled -eq $true + $isDisabled = -not $isEnabled + $groupProperty = $setting.PSObject.Properties['enabledSecurityGroups'] + $enabledGroups = if ($null -eq $groupProperty) { @() } else { @($groupProperty.Value | Where-Object { $_ }) } + $hasGroups = $enabledGroups.Count -gt 0 + $scope = if ($isDisabled) { 'Not applicable' } elseif ($hasGroups) { "$($enabledGroups.Count) security group(s)" } else { 'Entire organization' } + $additionalCondition = 'Not applicable' + $createP2wIsBoolean = $false + $createP2wIsDisabled = $false + + if ($Rule -eq 'PublishToWeb' -and $isEnabled) { + $propertiesProperty = $setting.PSObject.Properties['properties'] + $createP2wProperties = if ($null -eq $propertiesProperty -or $null -eq $propertiesProperty.Value) { + @() + } + else { + @($propertiesProperty.Value | Where-Object { $_.name -eq 'CreateP2w' }) + } + + $createP2wValue = if ($createP2wProperties.Count -eq 1) { $createP2wProperties[0].value } else { $null } + $parsedCreateP2wValue = $false + $createP2wIsBoolean = $createP2wValue -is [string] -and [bool]::TryParse($createP2wValue, [ref] $parsedCreateP2wValue) + $createP2wIsDisabled = $createP2wIsBoolean -and -not $parsedCreateP2wValue + $additionalCondition = if (-not $createP2wIsBoolean) { + 'Not found or invalid' + } + elseif ($createP2wIsDisabled) { + 'Existing codes only' + } + else { + 'New codes allowed' + } + } + + switch ($Rule) { + 'DisabledOrGroups' { + $testResult = $isDisabled -or ($isEnabled -and $hasGroups) + } + 'PublishToWeb' { + $testResult = $isDisabled -or ($isEnabled -and $hasGroups -and $createP2wIsDisabled) + } + 'Disabled' { + $testResult = $isDisabled + } + 'Enabled' { + $testResult = $isEnabled + } + } + + $stateText = if ($isDisabled) { 'disabled' } elseif ($hasGroups) { "enabled for $($enabledGroups.Count) security group(s)" } else { 'enabled for the entire organization' } + if ($Rule -eq 'PublishToWeb' -and $testResult -and $isEnabled) { + $stateText += ' with only existing embed codes allowed' + } + + $resultText = if ($testResult) { 'Pass' } else { 'Fail' } + $enabledText = if ($isEnabled) { 'True' } else { 'False' } + $resultMd = "| Setting | Enabled | Scope | Additional condition | Result |`n" + $resultMd += "| --- | --- | --- | --- | --- |`n" + $resultMd += "| $SettingTitle | $enabledText | $scope | $additionalCondition | $resultText |`n" + + if ($testResult) { + $resultMessage = "Well done. $SettingTitle is $stateText." + } + else { + $resultMessage = switch ($Rule) { + 'DisabledOrGroups' { "$SettingTitle is enabled for the entire organization. Disable it or restrict it to one or more security groups." } + 'PublishToWeb' { + $restrictionsToFix = @() + if (-not $hasGroups) { $restrictionsToFix += 'restrict it to one or more security groups' } + if (-not $createP2wIsBoolean) { + $restrictionsToFix += 'confirm that new embed codes are disabled' + } + elseif (-not $createP2wIsDisabled) { + $restrictionsToFix += 'allow only existing embed codes' + } + "$SettingTitle does not meet the required restrictions. Set it to " + ($restrictionsToFix -join ' and ') + '.' + } + 'Disabled' { "$SettingTitle is enabled. Disable it in Fabric tenant settings." } + 'Enabled' { "$SettingTitle is disabled. Enable it in Fabric tenant settings." } + } + } + + Add-MtTestResultDetail -Result "$resultMessage`n`n$resultMd" + return [bool] $testResult +} diff --git a/powershell/tests/fixtures/golden/selection.json b/powershell/tests/fixtures/golden/selection.json index ae970e7cfd..8c05571b8f 100644 --- a/powershell/tests/fixtures/golden/selection.json +++ b/powershell/tests/fixtures/golden/selection.json @@ -21,7 +21,7 @@ "AD" ] }, - "SelectedCount": 582, + "SelectedCount": 590, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -306,6 +306,14 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.POWERBI.1.1", + "CISA.MS.POWERBI.2.1", + "CISA.MS.POWERBI.3.1", + "CISA.MS.POWERBI.4.1", + "CISA.MS.POWERBI.4.2", + "CISA.MS.POWERBI.5.1", + "CISA.MS.POWERBI.6.1", + "CISA.MS.POWERBI.7.1", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -771,7 +779,7 @@ "AD" ] }, - "SelectedCount": 538, + "SelectedCount": 546, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -1056,6 +1064,14 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.POWERBI.1.1", + "CISA.MS.POWERBI.2.1", + "CISA.MS.POWERBI.3.1", + "CISA.MS.POWERBI.4.1", + "CISA.MS.POWERBI.4.2", + "CISA.MS.POWERBI.5.1", + "CISA.MS.POWERBI.6.1", + "CISA.MS.POWERBI.7.1", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -1330,7 +1346,7 @@ "AD" ] }, - "SelectedCount": 598, + "SelectedCount": 606, "SelectedFamilies": [ "MT.1024", "MT.1033", @@ -1618,6 +1634,14 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.POWERBI.1.1", + "CISA.MS.POWERBI.2.1", + "CISA.MS.POWERBI.3.1", + "CISA.MS.POWERBI.4.1", + "CISA.MS.POWERBI.4.2", + "CISA.MS.POWERBI.5.1", + "CISA.MS.POWERBI.6.1", + "CISA.MS.POWERBI.7.1", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -1951,7 +1975,7 @@ "AD" ] }, - "SelectedCount": 609, + "SelectedCount": 617, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -2237,6 +2261,14 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.POWERBI.1.1", + "CISA.MS.POWERBI.2.1", + "CISA.MS.POWERBI.3.1", + "CISA.MS.POWERBI.4.1", + "CISA.MS.POWERBI.4.2", + "CISA.MS.POWERBI.5.1", + "CISA.MS.POWERBI.6.1", + "CISA.MS.POWERBI.7.1", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -2581,7 +2613,7 @@ "AD" ] }, - "SelectedCount": 639, + "SelectedCount": 647, "SelectedFamilies": [ "MT.1024", "MT.1033", @@ -2870,6 +2902,14 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.POWERBI.1.1", + "CISA.MS.POWERBI.2.1", + "CISA.MS.POWERBI.3.1", + "CISA.MS.POWERBI.4.1", + "CISA.MS.POWERBI.4.2", + "CISA.MS.POWERBI.5.1", + "CISA.MS.POWERBI.6.1", + "CISA.MS.POWERBI.7.1", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -3441,7 +3481,7 @@ "AD" ] }, - "SelectedCount": 538, + "SelectedCount": 546, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -3726,6 +3766,14 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.POWERBI.1.1", + "CISA.MS.POWERBI.2.1", + "CISA.MS.POWERBI.3.1", + "CISA.MS.POWERBI.4.1", + "CISA.MS.POWERBI.4.2", + "CISA.MS.POWERBI.5.1", + "CISA.MS.POWERBI.6.1", + "CISA.MS.POWERBI.7.1", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -4006,7 +4054,7 @@ "AD" ] }, - "SelectedCount": 595, + "SelectedCount": 603, "SelectedFamilies": [ "MT.1024", "MT.1033", @@ -4295,6 +4343,14 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.POWERBI.1.1", + "CISA.MS.POWERBI.2.1", + "CISA.MS.POWERBI.3.1", + "CISA.MS.POWERBI.4.1", + "CISA.MS.POWERBI.4.2", + "CISA.MS.POWERBI.5.1", + "CISA.MS.POWERBI.6.1", + "CISA.MS.POWERBI.7.1", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", diff --git a/powershell/tests/functions/Get-MtFabricTenantSettings.Tests.ps1 b/powershell/tests/functions/Get-MtFabricTenantSettings.Tests.ps1 index 698443f52f..bd21f214ef 100644 --- a/powershell/tests/functions/Get-MtFabricTenantSettings.Tests.ps1 +++ b/powershell/tests/functions/Get-MtFabricTenantSettings.Tests.ps1 @@ -3,6 +3,11 @@ $script:fabricTestTokenKey = [byte[]](0..15) $script:encryptedFabricTestToken = '76492d1116743f0423413b16050a5345MgB8ADgAbwBvADMAWgBoAGcAYQBPAEYAMwBhAHQARgBCAEYAeQA3AHgAbQBlAFEAPQA9AHwAYwAwAGYANwBlADUAMAA1ADcANwBmAGUANABmAGMAMQAxAGIAMgAyADMANAA4ADcANQA5AGMAZAA5ADQAMwAyADEAOABjADQAOQBjAGYAOAA4ADMAZAA2AGEAZgA1ADcAMAA1ADEANABkADIANABlAGEANABhADgAOABkAGUAZQBhADAAYwAwADIAYgBiADgAMQBkAGQAMAA1AGEAMgAzAGIAYQA3ADQAMgBlAGUAMAA3AGMANQA1AGMAMwA2ADIANwA1ADgAZgBiAGUAOQBlADcAYgBlAGYAOQA2ADAAMAA4AGYAZgBkADQANAA5AGMAOQA2AGQAMQAyAGEANgA1ADQANQAwADcAMABhADkAYQAxADIAMwBhADMAMQAxAGIAZQBjADgAYgA4ADYAMgBkADIANABlAGMANgBlADcAMQA=' + if (-not (Get-Command Get-AzContext -ErrorAction SilentlyContinue)) { + function global:Get-AzContext {} + $script:removeAzContextStub = $true + } + if (-not (Get-Command Get-AzAccessToken -ErrorAction SilentlyContinue)) { function global:Get-AzAccessToken { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'ResourceUrl', Justification = 'Stub signature only; Mock binds -ResourceUrl from it.')] @@ -17,6 +22,9 @@ } AfterAll { + if ($script:removeAzContextStub) { + Remove-Item -Path Function:\Get-AzContext -ErrorAction SilentlyContinue + } if ($script:removeAzStub) { Remove-Item -Path Function:\Get-AzAccessToken -ErrorAction SilentlyContinue } @@ -25,6 +33,9 @@ AfterAll { Describe 'Get-MtFabricTenantSettings' { BeforeEach { InModuleScope Maester { $__MtSession.FabricCache = @{} } + Mock -ModuleName Maester Get-AzContext { + [pscustomobject]@{ Environment = [pscustomobject]@{ Name = 'AzureCloud' } } + } } It 'requests a secure Fabric token and returns the tenant settings' { @@ -56,6 +67,38 @@ Describe 'Get-MtFabricTenantSettings' { } } + It 'uses the GCC High token audience and tenant settings endpoint' { + Mock -ModuleName Maester Get-AzContext { + [pscustomobject]@{ Environment = [pscustomobject]@{ Name = 'AzureUSGovernment' } } + } + Mock -ModuleName Maester Get-AzAccessToken { + [pscustomobject]@{ Token = ConvertTo-SecureString -String $script:encryptedFabricTestToken -Key $script:fabricTestTokenKey } + } + Mock -ModuleName Maester Invoke-RestMethod { + [pscustomobject]@{ value = @([pscustomobject]@{ settingName = 'FirstSetting' }); continuationUri = $null } + } + + $settings = @(InModuleScope Maester { Get-MtFabricTenantSettings }) + + $settings | Should -HaveCount 1 + Should -Invoke Get-AzAccessToken -ModuleName Maester -Exactly -Times 1 -ParameterFilter { + $ResourceUrl -eq 'https://highapi.fabric.microsoft.us' -and $AsSecureString + } + Should -Invoke Invoke-RestMethod -ModuleName Maester -Exactly -Times 1 -ParameterFilter { + $Uri -eq 'https://highapi.fabric.microsoft.us/v1/admin/tenantsettings' + } + } + + It 'rejects unsupported Azure environments before requesting a token' { + Mock -ModuleName Maester Get-AzContext { + [pscustomobject]@{ Environment = [pscustomobject]@{ Name = 'AzureChinaCloud' } } + } + Mock -ModuleName Maester Get-AzAccessToken {} + + { InModuleScope Maester { Get-MtFabricTenantSettings } } | Should -Throw "*not supported in Azure environment 'AzureChinaCloud'*" + Should -Invoke Get-AzAccessToken -ModuleName Maester -Exactly -Times 0 + } + It 'follows continuationUri and combines settings from every page' { Mock -ModuleName Maester Get-AzAccessToken { [pscustomobject]@{ Token = ConvertTo-SecureString -String $script:encryptedFabricTestToken -Key $script:fabricTestTokenKey } diff --git a/powershell/tests/functions/Test-MtCisaPowerBiBaseline.Tests.ps1 b/powershell/tests/functions/Test-MtCisaPowerBiBaseline.Tests.ps1 new file mode 100644 index 0000000000..c41d1ea57f --- /dev/null +++ b/powershell/tests/functions/Test-MtCisaPowerBiBaseline.Tests.ps1 @@ -0,0 +1,165 @@ +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSReviewUnusedParameter', + '', + Justification = 'Pester passes Check through InModuleScope scriptblocks, which the analyzer does not follow.' +)] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSUseDeclaredVarsMoreThanAssignments', + '', + Justification = 'Pester shares BeforeDiscovery data with Describe -ForEach, which the analyzer does not follow.' +)] +param() + +BeforeDiscovery { + $powerBiChecks = @( + @{ Check = 'Test-MtCisaPowerBiPublishToWebDisabled'; Setting = 'PublishToWeb'; Enabled = $false; GroupScoped = $false } + @{ Check = 'Test-MtCisaPowerBiGuestAccessRestricted'; Setting = 'AllowGuestUserToAccessSharedContent'; Enabled = $false; GroupScoped = $true } + @{ Check = 'Test-MtCisaPowerBiGuestInvitationsRestricted'; Setting = 'ExternalSharingV2'; Enabled = $false; GroupScoped = $true } + @{ Check = 'Test-MtCisaPowerBiServicePrincipalApisRestricted'; Setting = 'ServicePrincipalAccessPermissionAPIs'; Enabled = $false; GroupScoped = $true } + @{ Check = 'Test-MtCisaPowerBiServicePrincipalProfilesRestricted'; Setting = 'AllowServicePrincipalsCreateAndUseProfiles'; Enabled = $false; GroupScoped = $true } + @{ Check = 'Test-MtCisaPowerBiResourceKeyAuthenticationBlocked'; Setting = 'BlockResourceKeyAuthentication'; Enabled = $true; GroupScoped = $false } + @{ Check = 'Test-MtCisaPowerBiScriptVisualsDisabled'; Setting = 'RScriptVisual'; Enabled = $false; GroupScoped = $false } + @{ Check = 'Test-MtCisaPowerBiSensitivityLabel'; Setting = 'EimInformationProtectionEdit'; Enabled = $true; GroupScoped = $false } + ) +} + +BeforeAll { + Import-Module "$PSScriptRoot\..\..\Maester.psd1" -Force +} + +Describe 'CISA Power BI baseline: ' -ForEach $powerBiChecks { + BeforeEach { + Mock -ModuleName Maester Add-MtTestResultDetail {} + } + + It 'accepts the audited enabled state' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { + [pscustomobject]@{ settingName = $Setting; enabled = $Enabled } + } + + $result = @(InModuleScope Maester -Parameters @{ Check = $Check } { + param($Check) + & $Check + }) + + $result | Should -HaveCount 1 + $result[0] | Should -BeOfType [bool] + $result[0] | Should -BeTrue + Should -Invoke Add-MtTestResultDetail -ModuleName Maester -Exactly -Times 1 -ParameterFilter { + -not $Investigate -and $Result -like 'Well done.*' + } + } + + It 'fails the opposite enabled state without a security-group scope' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { + [pscustomobject]@{ settingName = $Setting; enabled = -not $Enabled; enabledSecurityGroups = @() } + } + + InModuleScope Maester -Parameters @{ Check = $Check } { + param($Check) + & $Check | Should -BeFalse + } + Should -Invoke Add-MtTestResultDetail -ModuleName Maester -Exactly -Times 0 -ParameterFilter { $Investigate } + } + + It 'does not substitute an unrelated setting when the audited setting is missing' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { + [pscustomobject]@{ settingName = 'UnrelatedSetting'; enabled = $Enabled } + } + + InModuleScope Maester -Parameters @{ Check = $Check } { + param($Check) + { & $Check } | Should -Throw '*Expected exactly one Fabric tenant setting*' + } + } + + It 'errors on empty tenant settings' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { @() } + + InModuleScope Maester -Parameters @{ Check = $Check } { + param($Check) + { & $Check } | Should -Throw '*received 0*' + } + } + + It 'errors on duplicate audited settings' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { + [pscustomobject]@{ settingName = $Setting; enabled = $Enabled } + [pscustomobject]@{ settingName = $Setting; enabled = -not $Enabled } + } + + InModuleScope Maester -Parameters @{ Check = $Check } { + param($Check) + { & $Check } | Should -Throw '*received 2*' + } + } + + It 'errors when enabled is absent rather than coercing it to false' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { + [pscustomobject]@{ settingName = $Setting } + } + + InModuleScope Maester -Parameters @{ Check = $Check } { + param($Check) + { & $Check } | Should -Throw '*Boolean enabled value*' + } + } + + It 'errors when enabled is a string rather than a Boolean' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { + [pscustomobject]@{ settingName = $Setting; enabled = 'false' } + } + + InModuleScope Maester -Parameters @{ Check = $Check } { + param($Check) + { & $Check } | Should -Throw '*Boolean enabled value*' + } + } + + It 'accepts enabled group scope only where the audit permits it' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { + [pscustomobject]@{ + settingName = $Setting + enabled = $true + enabledSecurityGroups = @([pscustomobject]@{ graphId = 'approved-group'; name = 'Approved applications or users' }) + properties = @([pscustomobject]@{ name = 'CreateP2w'; value = 'false' }) + } + } + + InModuleScope Maester -Parameters @{ Check = $Check; Expected = $GroupScoped -or $Enabled } { + param($Check, $Expected) + & $Check | Should -Be $Expected + } + } +} + +Describe 'Power BI publish-to-web audit differs from CIS without changing CIS behavior' { + BeforeEach { + Mock -ModuleName Maester Add-MtTestResultDetail {} + Mock -ModuleName Maester Get-MtFabricTenantSettings { + [pscustomobject]@{ + settingName = 'PublishToWeb' + enabled = $true + enabledSecurityGroups = @([pscustomobject]@{ graphId = 'approved-group' }) + properties = @([pscustomobject]@{ name = 'CreateP2w'; value = 'false' }) + } + } + } + + It 'keeps the CIS group-scoped existing-code exception but fails SCuBA' { + InModuleScope Maester { + Test-MtCisFabricPublishToWebRestricted | Should -BeTrue + Test-MtCisaPowerBiPublishToWebDisabled | Should -BeFalse + } + } + + It 'propagates transport permission errors instead of reporting compliance' { + Mock -ModuleName Maester Get-MtFabricTenantSettings { throw '403 Forbidden' } + + InModuleScope Maester { + { Test-MtCisaPowerBiPublishToWebDisabled } | Should -Throw '*403 Forbidden*' + { Test-MtCisaPowerBiSensitivityLabel } | Should -Throw '*403 Forbidden*' + } + Should -Invoke Add-MtTestResultDetail -ModuleName Maester -Exactly -Times 0 + } +} diff --git a/powershell/tests/general/NativeTestLint.Tests.ps1 b/powershell/tests/general/NativeTestLint.Tests.ps1 index ce59de3242..c9cc586c65 100644 --- a/powershell/tests/general/NativeTestLint.Tests.ps1 +++ b/powershell/tests/general/NativeTestLint.Tests.ps1 @@ -153,6 +153,7 @@ Describe 'Product of the built-in tests' { 'maester/xspm' = 'defender' 'cisa/entra' = 'entra' 'cisa/exchange' = 'exchange' + 'cisa/fabric' = 'fabric' 'cisa/sharepoint' = 'sharepoint' 'asd/entra' = 'entra' 'asd/intune' = 'intune' diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.1.1.md b/tests/cisa/fabric/Test.CISA.MS.POWERBI.1.1.md new file mode 100644 index 0000000000..d5d821e175 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.1.1.md @@ -0,0 +1,22 @@ +Power BI **Publish to web** is disabled, as assessed by SCuBA MS.POWERBI.1.1v1. + +Public embed URLs require no sign-in and can expose report data to anyone, including an attacker collecting cloud data. This check reads the tenant's `PublishToWeb` setting and passes only when `enabled` is false. Missing, duplicated, or non-Boolean data produces an error, not a pass. + +Unlike [CIS.M365.9.1.4](https://maester.dev/docs/tests/CIS.M365.9.1.4), ScubaGear does not accept enabled publishing restricted to groups or existing embed codes. An agency-approved mission exception must be assessed and documented separately; it does not turn an enabled setting into an automated pass. + +#### Remediation action + +1. Sign in to the [Fabric / Power BI admin portal](https://app.powerbi.com/admin-portal) as a Fabric administrator. For government clouds, use the corresponding Power BI portal. +2. Open **Tenant settings** > **Export and sharing settings**. +3. Expand **Publish to web** and set it to **Disabled**. +4. Select **Apply**. Report publishers using public embedding will need an approved authenticated sharing alternative. +5. If the agency mission requires public publishing, document the exception and restrict publishing to specific security groups. Review public reports and embed codes separately; this audit does not inventory their content. + +#### Related links + +* [CISA Power BI baseline and implementation instructions](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/powerbi.md#1-publish-to-web) +* [ScubaGear Power BI audit policies](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/Rego/PowerBIConfig.rego) +* [Publish to web tenant settings](https://learn.microsoft.com/fabric/admin/service-admin-portal-export-sharing#publish-to-web) + + +%TestResult% diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.1.1.ps1 b/tests/cisa/fabric/Test.CISA.MS.POWERBI.1.1.ps1 new file mode 100644 index 0000000000..5bc8714643 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.1.1.ps1 @@ -0,0 +1,30 @@ +function Test-MtCisaPowerBiPublishToWebDisabled { + <# + .SYNOPSIS + Checks that Power BI Publish to web is disabled. + + .DESCRIPTION + Applies ScubaGear's PublishToWeb.enabled equals false audit. Public reports need no authentication. + Unlike CIS.M365.9.1.4, restricted creation of embed codes is not an automated pass. + #> + [MaesterTest( + Id = 'CISA.MS.POWERBI.1.1', + Title = 'Disable Power BI publishing to the public web', + Product = 'fabric', + Feature = 'export-and-sharing', + Area = 'external-access', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Medium', + ImplementationCost = 'Low', + Mitre = 'T1530', + Control = 'cisa-scuba:MS.POWERBI.1.1', + Service = 'Azure', + Author = 'JeremyFinney-lgtm' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtFabricTenantSetting -SettingName 'PublishToWeb' -SettingTitle 'Publish to web' -Rule Disabled +} diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.2.1.md b/tests/cisa/fabric/Test.CISA.MS.POWERBI.2.1.md new file mode 100644 index 0000000000..5bb64f91e2 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.2.1.md @@ -0,0 +1,21 @@ +Power BI guest access is disabled or restricted to specific security groups, as assessed by SCuBA MS.POWERBI.2.1v1. + +Limiting entry to the workload reduces exposure from compromised external cloud accounts. This check runs [CIS.M365.9.1.1](https://maester.dev/docs/tests/CIS.M365.9.1.1): the same `AllowGuestUserToAccessSharedContent` tenant setting and the same ScubaGear condition, disabled or a nonempty `enabledSecurityGroups` list. Missing or malformed enabled data produces an error. It does not assess group membership, mission justification, or individual item permissions. + +#### Remediation action + +1. Sign in to the [Fabric / Power BI admin portal](https://app.powerbi.com/admin-portal) as a Fabric administrator. For government clouds, use the corresponding Power BI portal. +2. Open **Tenant settings** > **Export and sharing settings**. +3. In commercial tenants, expand **Guest users can access Microsoft Fabric**. In GCC, GCC High, and DoD, use **Allow Azure Active Directory guest users to access Power BI**. +4. Set the feature to **Disabled** unless the agency mission requires guest access. +5. If guest access is required, set it to **Enabled**, select **Specific security groups**, and add the approved groups. Create dedicated groups if needed; review their membership and retain the mission justification. +6. Select **Apply**. Coordinate with affected collaborators because guests outside the allowed scope lose this access capability. + +#### Related links + +* [CISA Power BI guest access instructions](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/powerbi.md#2-power-bi-guest-access) +* [Fabric export and sharing settings](https://learn.microsoft.com/fabric/admin/service-admin-portal-export-sharing) +* [Power BI guest collaboration](https://learn.microsoft.com/power-bi/enterprise/service-admin-azure-ad-b2b) + + +%TestResult% diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.2.1.ps1 b/tests/cisa/fabric/Test.CISA.MS.POWERBI.2.1.ps1 new file mode 100644 index 0000000000..8f48fd8dae --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.2.1.ps1 @@ -0,0 +1,30 @@ +function Test-MtCisaPowerBiGuestAccessRestricted { + <# + .SYNOPSIS + Checks that Power BI guest access is disabled or restricted to security groups. + + .DESCRIPTION + Runs CIS.M365.9.1.1, whose tenant-setting scope and pass condition match ScubaGear MS.POWERBI.2.1v1. + Restricting access reduces exposure from compromised guest cloud accounts. + #> + [MaesterTest( + Id = 'CISA.MS.POWERBI.2.1', + Title = 'Restrict Power BI guest access', + Product = 'fabric', + Feature = 'export-and-sharing', + Area = 'external-access', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Medium', + ImplementationCost = 'Low', + Mitre = 'T1078.004', + Control = 'cisa-scuba:MS.POWERBI.2.1', + Service = 'Azure', + Author = 'JeremyFinney-lgtm' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisFabricGuestAccessRestricted +} diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.3.1.md b/tests/cisa/fabric/Test.CISA.MS.POWERBI.3.1.md new file mode 100644 index 0000000000..eda366f6de --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.3.1.md @@ -0,0 +1,24 @@ +Power BI external invitations are disabled or restricted to specific security groups, as assessed by SCuBA MS.POWERBI.3.1v1. + +Restricting invitations reduces uncontrolled creation of external guest accounts through sharing workflows. This check runs [CIS.M365.9.1.2](https://maester.dev/docs/tests/CIS.M365.9.1.2), evaluating `ExternalSharingV2` as disabled or with a nonempty `enabledSecurityGroups` list, matching ScubaGear. It does not review approved group membership or mission exceptions. Missing or malformed enabled data produces an error. + +Disabling invitations does not remove existing guests, their existing item access, or their appearance in user pickers. + +#### Remediation action + +1. Sign in to the [Fabric / Power BI admin portal](https://app.powerbi.com/admin-portal) as a Fabric administrator. For government clouds, use the corresponding Power BI portal. +2. Open **Tenant settings** > **Export and sharing settings**. +3. Expand **Users can invite guest users to collaborate through item sharing and permissions**. +4. Set it to **Disabled** unless the agency mission requires invitations through Power BI. +5. If invitations are needed, set it to **Enabled**, select **Specific security groups**, and specify groups containing only approved inviters. Create groups if needed and retain mission justification. +6. Select **Apply**. Notify affected users that new invitations must follow the approved workflow. +7. Review existing guest access separately if that access is no longer required. + +#### Related links + +* [CISA Power BI invitation instructions](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/powerbi.md#3-power-bi-external-invitations) +* [Fabric export and sharing settings](https://learn.microsoft.com/fabric/admin/service-admin-portal-export-sharing) +* [Power BI guest collaboration](https://learn.microsoft.com/power-bi/enterprise/service-admin-azure-ad-b2b) + + +%TestResult% diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.3.1.ps1 b/tests/cisa/fabric/Test.CISA.MS.POWERBI.3.1.ps1 new file mode 100644 index 0000000000..362a7a4ae6 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.3.1.ps1 @@ -0,0 +1,30 @@ +function Test-MtCisaPowerBiGuestInvitationsRestricted { + <# + .SYNOPSIS + Checks that Power BI guest invitations are disabled or restricted to security groups. + + .DESCRIPTION + Runs CIS.M365.9.1.2, whose tenant-setting scope and pass condition match ScubaGear MS.POWERBI.3.1v1. + This limits creation of external accounts through sharing workflows, not existing guest access. + #> + [MaesterTest( + Id = 'CISA.MS.POWERBI.3.1', + Title = 'Restrict Power BI external invitations', + Product = 'fabric', + Feature = 'export-and-sharing', + Area = 'external-access', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Medium', + ImplementationCost = 'Low', + Mitre = 'T1136.003', + Control = 'cisa-scuba:MS.POWERBI.3.1', + Service = 'Azure', + Author = 'JeremyFinney-lgtm' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisFabricGuestInvitationsRestricted +} diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.1.md b/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.1.md new file mode 100644 index 0000000000..b81475cb2c --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.1.md @@ -0,0 +1,24 @@ +Service-principal access to Fabric public APIs is disabled or limited to specific security groups, as assessed by SCuBA MS.POWERBI.4.1v1. + +Restricting the setting limits which compromised cloud application identities can use workload APIs. This check runs [CIS.M365.9.1.10](https://maester.dev/docs/tests/CIS.M365.9.1.10), checking `ServicePrincipalAccessPermissionAPIs` as disabled or with a nonempty `enabledSecurityGroups` list, matching ScubaGear. Missing or malformed enabled data produces an error. + +This is not the separate setting for read-only admin APIs or the setting for creating workspaces, connections, and deployment pipelines. The audit does not inspect group membership, credentials, or permissions on individual items. + +#### Remediation action + +1. Sign in to the [Fabric / Power BI admin portal](https://app.powerbi.com/admin-portal) as a Fabric administrator. For government clouds, use the corresponding Power BI portal. +2. Open **Tenant settings** > **Developer settings**. +3. Expand **Service principals can call Fabric public APIs**. +4. If no service principal needs these APIs, set the feature to **Disabled**. +5. Otherwise set it to **Enabled**, select **Specific security groups**, and specify dedicated groups containing the authorized service principals. +6. Select **Apply** and review group membership and application access regularly. The restriction concerns application identities; it does not change ordinary end-user workflows. +7. Where service principals use credentials, follow the baseline's recommendation to store them in a key vault with appropriately assigned access policies and regularly reviewed permissions. Credential storage is a separate human assessment. + +#### Related links + +* [CISA Power BI service-principal instructions](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/powerbi.md#4-power-bi-service-principals) +* [Fabric developer settings](https://learn.microsoft.com/fabric/admin/service-admin-portal-developer#service-principals-can-call-fabric-public-apis) +* [Power BI service-principal embedding](https://learn.microsoft.com/power-bi/developer/embedded/embed-service-principal) + + +%TestResult% diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.1.ps1 b/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.1.ps1 new file mode 100644 index 0000000000..120430a603 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.1.ps1 @@ -0,0 +1,30 @@ +function Test-MtCisaPowerBiServicePrincipalApisRestricted { + <# + .SYNOPSIS + Checks that service-principal access to Fabric public APIs is disabled or group-restricted. + + .DESCRIPTION + Runs CIS.M365.9.1.10, whose tenant-setting scope and pass condition match ScubaGear MS.POWERBI.4.1v1. + Restricting access limits which compromised application identities can call these APIs. + #> + [MaesterTest( + Id = 'CISA.MS.POWERBI.4.1', + Title = 'Restrict Power BI service-principal API access', + Product = 'fabric', + Feature = 'developer-settings', + Area = 'applications', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = 'T1078.004', + Control = 'cisa-scuba:MS.POWERBI.4.1', + Service = 'Azure', + Author = 'JeremyFinney-lgtm' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisFabricPublicApiAccessRestricted +} diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.2.md b/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.2.md new file mode 100644 index 0000000000..417fbe7862 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.2.md @@ -0,0 +1,21 @@ +Service-principal creation and use of profiles is disabled or restricted to specific security groups, as assessed by SCuBA MS.POWERBI.4.2v1. + +Profiles support multitenant applications. Limiting eligible cloud application identities reduces the impact of compromised service principals using profiles across customer boundaries. This check runs [CIS.M365.9.1.11](https://maester.dev/docs/tests/CIS.M365.9.1.11), evaluating `AllowServicePrincipalsCreateAndUseProfiles` as disabled or with a nonempty `enabledSecurityGroups` list, matching ScubaGear. Missing or malformed enabled data produces an error. It does not inspect profiles, their permissions, or group membership. + +#### Remediation action + +1. Sign in to the [Fabric / Power BI admin portal](https://app.powerbi.com/admin-portal) as a Fabric administrator. For government clouds, use the corresponding Power BI portal. +2. Open **Tenant settings** > **Developer settings**. +3. Expand **Allow service principals to create and use profiles**. +4. If no service principal needs profiles, set it to **Disabled**. +5. Otherwise set it to **Enabled**, select **Specific security groups**, and specify groups containing only service principals authorized to create and use profiles. +6. Select **Apply**. Review group membership and profile permissions separately. The tenant restriction affects application identities rather than ordinary end users. + +#### Related links + +* [CISA Power BI service-principal instructions](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/powerbi.md#4-power-bi-service-principals) +* [Fabric profile tenant setting](https://learn.microsoft.com/fabric/admin/service-admin-portal-developer#allow-service-principals-to-create-and-use-profiles) +* [Service-principal profiles for multitenancy](https://learn.microsoft.com/power-bi/developer/embedded/embed-multi-tenancy) + + +%TestResult% diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.2.ps1 b/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.2.ps1 new file mode 100644 index 0000000000..f059e8e964 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.4.2.ps1 @@ -0,0 +1,30 @@ +function Test-MtCisaPowerBiServicePrincipalProfilesRestricted { + <# + .SYNOPSIS + Checks that service-principal profiles are disabled or restricted to security groups. + + .DESCRIPTION + Runs CIS.M365.9.1.11, whose tenant-setting scope and pass condition match ScubaGear MS.POWERBI.4.2v1. + This limits profile access by compromised cloud application identities. + #> + [MaesterTest( + Id = 'CISA.MS.POWERBI.4.2', + Title = 'Restrict Power BI service-principal profiles', + Product = 'fabric', + Feature = 'developer-settings', + Area = 'applications', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = 'T1078.004', + Control = 'cisa-scuba:MS.POWERBI.4.2', + Service = 'Azure', + Author = 'JeremyFinney-lgtm' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisFabricServicePrincipalProfilesRestricted +} diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.5.1.md b/tests/cisa/fabric/Test.CISA.MS.POWERBI.5.1.md new file mode 100644 index 0000000000..643ec369ef --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.5.1.md @@ -0,0 +1,23 @@ +ResourceKey-based authentication is blocked for Power BI streaming and push datasets, as assessed by SCuBA MS.POWERBI.5.1v1. + +A resource key in a URL can authorize data writes without an Entra OAuth bearer token. Blocking this shared-key path requires an identity-based authentication alternative. This check runs [CIS.M365.9.1.9](https://maester.dev/docs/tests/CIS.M365.9.1.9), passing only when `BlockResourceKeyAuthentication.enabled` is true, matching ScubaGear. Missing or malformed enabled data produces an error. + +The setting applies tenant-wide, not to selected groups. An approved streaming or push use case is a separately documented exception, not an automated pass. + +#### Remediation action + +1. Identify integrations that send data using resource keys and coordinate migration to an approved identity-based authentication method with their owners. +2. Sign in to the [Fabric / Power BI admin portal](https://app.powerbi.com/admin-portal) as a Fabric administrator. For government clouds, use the corresponding Power BI portal. +3. Open **Tenant settings** > **Developer settings**. +4. Expand **Block ResourceKey authentication** and set it to **Enabled**, as directed by the SCuBA implementation procedure. +5. Select **Apply**. Pilot the integration changes because resource-key clients will no longer be able to push data using that authentication path. +6. If a specific use case merits resource keys, retain its justification, authorization, and risk review. The enabled blocking condition remains the automated audit standard. + +#### Related links + +* [CISA resource-key implementation instructions](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/powerbi.md#5-power-bi-resource-key-authentication) +* [Fabric developer settings](https://learn.microsoft.com/fabric/admin/service-admin-portal-developer#block-resourcekey-authentication) +* [Power BI real-time streaming](https://learn.microsoft.com/power-bi/connect-data/service-real-time-streaming) + + +%TestResult% diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.5.1.ps1 b/tests/cisa/fabric/Test.CISA.MS.POWERBI.5.1.ps1 new file mode 100644 index 0000000000..c123d31c33 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.5.1.ps1 @@ -0,0 +1,30 @@ +function Test-MtCisaPowerBiResourceKeyAuthenticationBlocked { + <# + .SYNOPSIS + Checks that resource-key authentication is blocked for streaming and push datasets. + + .DESCRIPTION + Runs CIS.M365.9.1.9, whose tenant-setting scope and pass condition match ScubaGear MS.POWERBI.5.1v1. + Blocking shared resource keys requires clients to use identity-based authentication. + #> + [MaesterTest( + Id = 'CISA.MS.POWERBI.5.1', + Title = 'Block Power BI resource-key authentication', + Product = 'fabric', + Feature = 'developer-settings', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Medium', + ImplementationCost = 'Medium', + Mitre = 'None', + Control = 'cisa-scuba:MS.POWERBI.5.1', + Service = 'Azure', + Author = 'JeremyFinney-lgtm' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisFabricResourceKeyAuthenticationBlocked +} diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.6.1.md b/tests/cisa/fabric/Test.CISA.MS.POWERBI.6.1.md new file mode 100644 index 0000000000..ce43fd1ae8 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.6.1.md @@ -0,0 +1,20 @@ +Power BI R and Python visual interactions are disabled, as assessed by SCuBA MS.POWERBI.6.1v1. + +User-authored visual scripts can introduce code-execution and privacy risks through report content. This check runs [CIS.M365.9.1.5](https://maester.dev/docs/tests/CIS.M365.9.1.5), passing only when `RScriptVisual.enabled` is false, matching ScubaGear. This is a tenant feature restriction, not an assessment of individual script safety. Missing or malformed enabled data produces an error. + +#### Remediation action + +1. Identify reports using R or Python visuals and coordinate supported replacement visuals with their owners. Some users will need to change reports or workflows. +2. Sign in to the [Fabric / Power BI admin portal](https://app.powerbi.com/admin-portal) as a Fabric administrator. For government clouds, use the corresponding Power BI portal. +3. Open **Tenant settings** > **R and Python visuals settings**. +4. Expand **Interact with and share R and Python visuals** and set it to **Disabled**. +5. Select **Apply** and validate affected reports. ScubaGear does not treat enabled interactions restricted to security groups as a pass. + +#### Related links + +* [CISA R and Python implementation instructions](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/powerbi.md#6-python-and-r-visual-sharing) +* [R and Python visuals admin settings](https://learn.microsoft.com/fabric/admin/service-admin-portal-r-python-visuals) +* [Power BI Python visuals](https://learn.microsoft.com/power-bi/connect-data/desktop-python-visuals) + + +%TestResult% diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.6.1.ps1 b/tests/cisa/fabric/Test.CISA.MS.POWERBI.6.1.ps1 new file mode 100644 index 0000000000..5093a9490e --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.6.1.ps1 @@ -0,0 +1,30 @@ +function Test-MtCisaPowerBiScriptVisualsDisabled { + <# + .SYNOPSIS + Checks that Power BI R and Python visuals are disabled. + + .DESCRIPTION + Runs CIS.M365.9.1.5, whose tenant-setting scope and pass condition match ScubaGear MS.POWERBI.6.1v1. + Disabling user-authored script visuals reduces script-based execution through report content. + #> + [MaesterTest( + Id = 'CISA.MS.POWERBI.6.1', + Title = 'Disable Power BI R and Python interactions', + Product = 'fabric', + Feature = 'tenant-settings', + Area = 'infrastructure', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Medium', + ImplementationCost = 'Medium', + Mitre = 'T1059', + Control = 'cisa-scuba:MS.POWERBI.6.1', + Service = 'Azure', + Author = 'JeremyFinney-lgtm' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisFabricScriptVisualsDisabled +} diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.7.1.md b/tests/cisa/fabric/Test.CISA.MS.POWERBI.7.1.md new file mode 100644 index 0000000000..3b6ae2a019 --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.7.1.md @@ -0,0 +1,25 @@ +Sensitivity labels are enabled and employed on sensitive Power BI data according to enterprise policy, as required by SCuBA MS.POWERBI.7.1v1. + +This check reuses [CIS.M365.9.1.6](https://maester.dev/docs/tests/CIS.M365.9.1.6) for ScubaGear's automated condition: `EimInformationProtectionEdit.enabled` must be true. Enabled labeling passes and disabled labeling fails; missing or malformed enabled data produces an error. A pass shows only that labels are available: it does not establish that labels are published or used on sensitive content. + +Sensitivity labels help users recognize data classification and protect supported export paths, but do not replace item permissions or guarantee protection on every sharing path. Label publication and use on sensitive content require separate evidence; review them with the remediation steps below. No license gate is declared: an absent license must not hide a disabled setting; licensing prerequisites must be reviewed during remediation. + +#### Remediation action + +1. In [Microsoft Purview](https://purview.microsoft.com), define sensitivity labels and publish label policies to the relevant users and groups under **Solutions** > **Information Protection**. Migrate legacy Azure Information Protection labels to unified labeling if applicable. +2. Verify the baseline's licensing prerequisites: Information Protection Premium P1 or P2 for label application/viewing and Power BI Pro or Premium Per User for users applying labels to Power BI content. +3. Sign in to the [Fabric / Power BI admin portal](https://app.powerbi.com/admin-portal) as a Fabric administrator. For government clouds, use the corresponding Power BI portal. +4. Open **Tenant settings** > **Information protection** > **Allow users to apply sensitivity labels for content** and set it to **Enabled**. +5. Define who can apply and change labels: the entire organization or the appropriate specific security groups. Ensure those users also have the necessary create and edit permissions on their content, then select **Apply**. +6. With data owners, review sensitive reports, dashboards, semantic models (datasets), and dataflows against the enterprise classification and data protection policy. Apply the required labels where supported and check appropriate protection on exports. +7. Retain evidence of published policies, authorized labeling scope, and sensitive-content review for the organization's assessment process; the tenant-setting audit alone cannot establish label use. + +#### Related links + +* [CISA sensitive-data requirement and implementation instructions](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/powerbi.md#7-power-bi-sensitive-data) +* [Enable sensitivity labels in Fabric and Power BI](https://learn.microsoft.com/fabric/enterprise/powerbi/service-security-enable-data-sensitivity-labels) +* [Create and configure sensitivity labels](https://learn.microsoft.com/purview/create-sensitivity-labels) +* [Sensitivity label limitations](https://learn.microsoft.com/power-bi/enterprise/service-security-sensitivity-label-overview) + + +%TestResult% diff --git a/tests/cisa/fabric/Test.CISA.MS.POWERBI.7.1.ps1 b/tests/cisa/fabric/Test.CISA.MS.POWERBI.7.1.ps1 new file mode 100644 index 0000000000..9e1699fdcf --- /dev/null +++ b/tests/cisa/fabric/Test.CISA.MS.POWERBI.7.1.ps1 @@ -0,0 +1,30 @@ +function Test-MtCisaPowerBiSensitivityLabel { + <# + .SYNOPSIS + Checks that users can apply sensitivity labels to Power BI content. + + .DESCRIPTION + Reuses CIS.M365.9.1.6 for ScubaGear's automated EimInformationProtectionEdit.enabled equals true audit. + Label publication and use on sensitive content are covered by the remediation guidance, not this tenant-setting audit. + #> + [MaesterTest( + Id = 'CISA.MS.POWERBI.7.1', + Title = 'Enable and employ Power BI sensitivity labels', + Product = 'fabric', + Feature = 'information-protection', + Area = 'data-protection', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Medium', + Mitre = 'None', + Control = 'cisa-scuba:MS.POWERBI.7.1', + Service = 'Azure', + Author = 'JeremyFinney-lgtm' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return [bool](Test-MtCisFabricSensitivityLabelsEnabled) +} diff --git a/tests/cisa/frameworks/cisa-scuba.json b/tests/cisa/frameworks/cisa-scuba.json index 75246535de..61c5cf1a95 100644 --- a/tests/cisa/frameworks/cisa-scuba.json +++ b/tests/cisa/frameworks/cisa-scuba.json @@ -84,6 +84,14 @@ { "Id": "MS.SHAREPOINT.2.2", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SHAREPOINT.2.2v1" }, "Related": ["nist-800-53-r5:AC-6"] }, { "Id": "MS.SHAREPOINT.3.1", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SHAREPOINT.3.1v1" }, "Related": ["nist-800-53-r5:AC-3", "nist-800-53-r5:AC-21b"] }, { "Id": "MS.SHAREPOINT.3.2", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SHAREPOINT.3.2v1" }, "Related": ["nist-800-53-r5:AC-6"] }, - { "Id": "MS.SHAREPOINT.3.3", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SHAREPOINT.3.3v2" }, "Related": ["nist-800-53-r5:IA-11"] } + { "Id": "MS.SHAREPOINT.3.3", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SHAREPOINT.3.3v2" }, "Related": ["nist-800-53-r5:IA-11"] }, + { "Id": "MS.POWERBI.1.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.POWERBI.1.1v1" }, "Related": ["nist-800-53-r5:CM-7", "nist-800-53-r5:SC-7(10)(a)"] }, + { "Id": "MS.POWERBI.2.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.POWERBI.2.1v1" }, "Related": ["nist-800-53-r5:CM-7", "nist-800-53-r5:AC-6"] }, + { "Id": "MS.POWERBI.3.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.POWERBI.3.1v1" }, "Related": ["nist-800-53-r5:CM-7", "nist-800-53-r5:AC-6"] }, + { "Id": "MS.POWERBI.4.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.POWERBI.4.1v1" }, "Related": ["nist-800-53-r5:AC-4", "nist-800-53-r5:AC-6(5)"] }, + { "Id": "MS.POWERBI.4.2", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.POWERBI.4.2v1" }, "Related": ["nist-800-53-r5:AC-4", "nist-800-53-r5:AC-6(5)"] }, + { "Id": "MS.POWERBI.5.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.POWERBI.5.1v1" }, "Related": ["nist-800-53-r5:CM-7", "nist-800-53-r5:IA-5g"] }, + { "Id": "MS.POWERBI.6.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.POWERBI.6.1v1" }, "Related": ["nist-800-53-r5:CM-7", "nist-800-53-r5:SI-3"] }, + { "Id": "MS.POWERBI.7.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.POWERBI.7.1v1" }, "Related": ["nist-800-53-r5:AC-21b", "nist-800-53-r5:SC-7(10)(a)"] } ] }