Skip to content

Commit 0a296f9

Browse files
authored
Merge pull request #148 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 2420998 + c0eae0f commit 0a296f9

File tree

6 files changed

+81
-19
lines changed

6 files changed

+81
-19
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecAzBobbyTables.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ function Invoke-ExecAzBobbyTables {
1919

2020
$AllowList = @(
2121
'Add-AzDataTableEntity'
22+
'Add-CIPPAzDataTableEntity'
2223
'Update-AzDataTableEntity'
2324
'Get-AzDataTableEntity'
25+
'Get-CIPPAzDataTableEntity'
2426
'Get-AzDataTable'
2527
'New-AzDataTable'
2628
'Remove-AzDataTableEntity'
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
function Invoke-ListExtensionCacheData {
2+
<#
3+
.SYNOPSIS
4+
List Extension Cache Data
5+
.DESCRIPTION
6+
This function is used to list the extension cache data.
7+
.FUNCTIONALITY
8+
Entrypoint
9+
.ROLE
10+
CIPP.Core.Read
11+
#>
12+
[CmdletBinding()]
13+
param($Request, $TriggerMetadata)
14+
15+
$APIName = $Request.Params.CIPPEndpoint
16+
$Headers = $Request.Headers
17+
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
18+
19+
$TenantFilter = $Request.Query.tenantFilter ?? $Request.Body.tenantFilter
20+
$DataTypes = $Request.Query.dataTypes -split ',' ?? $Request.Body.dataTypes ?? 'All'
21+
22+
$Data = Get-ExtensionCacheData -TenantFilter $TenantFilter
23+
24+
if ($DataTypes -ne 'All') {
25+
$Data = $Data | Select-Object $DataTypes
26+
}
27+
28+
if (!$Data) {
29+
$Results = @{}
30+
}
31+
32+
$Body = @{
33+
Results = $Data
34+
}
35+
36+
$StatusCode = [HttpStatusCode]::OK
37+
38+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
39+
StatusCode = $StatusCode
40+
Body = $Body | ConvertTo-Json -Compress -Depth 100
41+
Headers = @{
42+
'Content-Type' = 'application/json'
43+
}
44+
})
45+
}

Modules/CIPPCore/Public/GraphHelper/New-ExoBulkRequest.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function New-ExoBulkRequest {
106106
if ($body.'@adminapi.warnings') {
107107
Write-Warning ($body.'@adminapi.warnings' | Out-String)
108108
}
109-
if ($body.error) {
109+
if (![string]::IsNullOrEmpty($body.error.details.message) -or ![string]::IsNullOrEmpty($body.error.message)) {
110110
if ($body.error.details.message) {
111111
$msg = [pscustomobject]@{ error = $body.error.details.message; target = $body.error.details.target }
112112
} else {
@@ -130,7 +130,7 @@ function New-ExoBulkRequest {
130130
if ($body.'@adminapi.warnings') {
131131
Write-Warning ($body.'@adminapi.warnings' | Out-String)
132132
}
133-
if ($body.error) {
133+
if (![string]::IsNullOrEmpty($body.error.details.message) -or ![string]::IsNullOrEmpty($body.error.message)) {
134134
if ($body.error.details.message) {
135135
$msg = [pscustomobject]@{ error = $body.error.details.message; target = $body.error.details.target }
136136
} else {

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardOauthConsent.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ function Invoke-CIPPStandardOauthConsent {
3232
#>
3333

3434
param($tenant, $settings)
35-
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'OauthConsent'
3635

3736
$State = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy' -tenantid $tenant
3837
$StateIsCorrect = if ($State.permissionGrantPolicyIdsAssignedToDefaultUserRole -eq 'managePermissionGrantsForSelf.cipp-consent-policy') { $true } else { $false }
3938

40-
If ($Settings.remediate -eq $true) {
39+
if ($Settings.remediate -eq $true) {
4140
$AllowedAppIdsForTenant = $settings.AllowedApps -split ','
4241
try {
4342
if ($State.permissionGrantPolicyIdsAssignedToDefaultUserRole -notin @('managePermissionGrantsForSelf.cipp-consent-policy')) {
@@ -70,11 +69,17 @@ function Invoke-CIPPStandardOauthConsent {
7069
if ($StateIsCorrect -eq $true) {
7170
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Application Consent Mode is enabled.' -sev Info
7271
} else {
73-
Write-StandardsAlert -message "Application Consent Mode is not enabled." -object $State -tenant $tenant -standardName 'OauthConsent' -standardId $Settings.standardId
72+
Write-StandardsAlert -message 'Application Consent Mode is not enabled.' -object $State -tenant $tenant -standardName 'OauthConsent' -standardId $Settings.standardId
7473
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Application Consent Mode is not enabled.' -sev Info
7574
}
7675
}
7776
if ($Settings.report -eq $true) {
7877
Add-CIPPBPAField -FieldName 'OauthConsent' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant
78+
if ($StateIsCorrect) {
79+
$FieldValue = $true
80+
} else {
81+
$FieldValue = $State
82+
}
83+
Set-CIPPStandardsCompareField -FieldName 'standards.OauthConsent' -FieldValue $FieldValue -Tenant $tenant
7984
}
8085
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardOauthConsentLowSec.ps1

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,23 @@ function Invoke-CIPPStandardOauthConsentLowSec {
2828
#>
2929

3030
param($Tenant, $Settings)
31-
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'OauthConsentLowSec'
3231

3332
$State = (New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy' -tenantid $tenant)
3433
$PermissionState = (New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/servicePrincipals(appId='00000003-0000-0000-c000-000000000000')/delegatedPermissionClassifications" -tenantid $tenant) | Select-Object -Property permissionName
3534

3635
$requiredPermissions = @('offline_access', 'openid', 'User.Read', 'profile', 'email')
3736
$missingPermissions = $requiredPermissions | Where-Object { $PermissionState.permissionName -notcontains $_ }
3837

39-
If ($Settings.remediate -eq $true) {
38+
if ($Settings.remediate -eq $true) {
4039
if ($State.permissionGrantPolicyIdsAssignedToDefaultUserRole -in @('managePermissionGrantsForSelf.microsoft-user-default-low')) {
4140
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Application Consent Mode(microsoft-user-default-low) is already enabled.' -sev Info
4241
} else {
4342
try {
4443
$GraphParam = @{
45-
tenantid = $tenant
46-
Uri = 'https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy'
47-
Type = 'PATCH'
48-
Body = @{
44+
tenantid = $tenant
45+
Uri = 'https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy'
46+
Type = 'PATCH'
47+
Body = @{
4948
permissionGrantPolicyIdsAssignedToDefaultUserRole = @('managePermissionGrantsForSelf.microsoft-user-default-low')
5049
} | ConvertTo-Json
5150
ContentType = 'application/json'
@@ -64,10 +63,10 @@ function Invoke-CIPPStandardOauthConsentLowSec {
6463
try {
6564
$missingPermissions | ForEach-Object {
6665
$GraphParam = @{
67-
tenantid = $tenant
68-
Uri = "https://graph.microsoft.com/beta/servicePrincipals(appId='00000003-0000-0000-c000-000000000000')/delegatedPermissionClassifications"
69-
Type = 'POST'
70-
Body = @{
66+
tenantid = $tenant
67+
Uri = "https://graph.microsoft.com/beta/servicePrincipals(appId='00000003-0000-0000-c000-000000000000')/delegatedPermissionClassifications"
68+
Type = 'POST'
69+
Body = @{
7170
permissionName = $_
7271
classification = 'low'
7372
} | ConvertTo-Json
@@ -85,7 +84,7 @@ function Invoke-CIPPStandardOauthConsentLowSec {
8584

8685
if ($Settings.alert -eq $true) {
8786
if ($State.permissionGrantPolicyIdsAssignedToDefaultUserRole -notin @('managePermissionGrantsForSelf.microsoft-user-default-low')) {
88-
Write-StandardsAlert -message "Application Consent Mode(microsoft-user-default-low) is not enabled" -object $State -tenant $tenant -standardName 'OauthConsentLowSec' -standardId $Settings.standardId
87+
Write-StandardsAlert -message 'Application Consent Mode(microsoft-user-default-low) is not enabled' -object $State -tenant $tenant -standardName 'OauthConsentLowSec' -standardId $Settings.standardId
8988
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Application Consent Mode(microsoft-user-default-low) is not enabled.' -sev Info
9089
} else {
9190
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Application Consent Mode(microsoft-user-default-low) is enabled.' -sev Info
@@ -95,9 +94,15 @@ function Invoke-CIPPStandardOauthConsentLowSec {
9594
if ($Settings.report -eq $true) {
9695
if ($State.permissionGrantPolicyIdsAssignedToDefaultUserRole -notin @('managePermissionGrantsForSelf.microsoft-user-default-low')) {
9796
$State.permissionGrantPolicyIdsAssignedToDefaultUserRole = $false
97+
$ValueField = @{
98+
authorizationPolicy = $State
99+
permissionClassifications = $PermissionState
100+
}
98101
} else {
99102
$State.permissionGrantPolicyIdsAssignedToDefaultUserRole = $true
103+
$ValueField = $true
100104
}
101105
Add-CIPPBPAField -FieldName 'OauthConsentLowSec' -FieldValue $State.permissionGrantPolicyIdsAssignedToDefaultUserRole -StoreAs bool -Tenant $tenant
106+
Set-CIPPStandardsCompareField -FieldName 'standards.OauthConsentLowSec' -FieldValue $ValueField -Tenant $tenant
102107
}
103108
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardOutBoundSpamAlert.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ function Invoke-CIPPStandardOutBoundSpamAlert {
3131
#>
3232

3333
param($Tenant, $Settings)
34-
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'OutBoundSpamAlert'
3534

3635
$CurrentInfo = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-HostedOutboundSpamFilterPolicy' -useSystemMailbox $true
3736

38-
If ($Settings.remediate -eq $true) {
37+
if ($Settings.remediate -eq $true) {
3938

4039
if ($CurrentInfo.NotifyOutboundSpam -ne $true -or $CurrentInfo.NotifyOutboundSpamRecipients -ne $settings.OutboundSpamContact) {
4140
$Contacts = $settings.OutboundSpamContact
@@ -56,12 +55,18 @@ function Invoke-CIPPStandardOutBoundSpamAlert {
5655
if ($CurrentInfo.NotifyOutboundSpam -eq $true) {
5756
Write-LogMessage -API 'Standards' -tenant $tenant -message "Outbound spam filter alert is set to $($CurrentInfo.NotifyOutboundSpamRecipients)" -sev Info
5857
} else {
59-
Write-StandardsAlert -message "Outbound spam filter alert is not set" -object $CurrentInfo -tenant $tenant -standardName 'OutBoundSpamAlert' -standardId $Settings.standardId
58+
Write-StandardsAlert -message 'Outbound spam filter alert is not set' -object $CurrentInfo -tenant $tenant -standardName 'OutBoundSpamAlert' -standardId $Settings.standardId
6059
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Outbound spam filter alert is not set' -sev Info
6160
}
6261
}
6362

6463
if ($Settings.report -eq $true) {
6564
Add-CIPPBPAField -FieldName 'OutboundSpamAlert' -FieldValue $CurrentInfo.NotifyOutboundSpam -StoreAs bool -Tenant $tenant
65+
if ($CurrentInfo.NotifyOutboundSpam -ne $true -or $CurrentInfo.NotifyOutboundSpamRecipients -ne $settings.OutboundSpamContact) {
66+
$ValueField = $CurrentInfo | Select-Object -Property NotifyOutboundSpamRecipients, NotifyOutboundSpam
67+
} else {
68+
$ValueField = $true
69+
}
70+
Set-CIPPStandardsCompareField -FieldName 'standards.OutBoundSpamAlert' -FieldValue $ValueField -Tenant $tenant
6671
}
6772
}

0 commit comments

Comments
 (0)