Skip to content

Commit 4b475d8

Browse files
authored
Merge pull request #498 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents f3dd1fa + bcb4157 commit 4b475d8

File tree

7 files changed

+139
-29
lines changed

7 files changed

+139
-29
lines changed

Modules/CIPPCore/Public/Alerts/Get-CippAlertBreachAlert.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Get-CippAlertBreachAlert {
1212
)
1313
try {
1414
$Search = New-BreachTenantSearch -TenantFilter $TenantFilter
15-
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $Search
15+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $Search -PartitionKey BreachAlert
1616
} catch {
1717
Write-AlertMessage -tenant $($TenantFilter) -message "Could not get New Breaches for $($TenantFilter): $(Get-NormalizedError -message $_.Exception.message)"
1818
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
function Push-ListTenantAllowBlockListAllTenants {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
#>
6+
[CmdletBinding()]
7+
param($Item)
8+
9+
$Tenant = Get-Tenants -TenantFilter $Item.customerId
10+
$domainName = $Tenant.defaultDomainName
11+
$Table = Get-CIPPTable -TableName 'cacheTenantAllowBlockList'
12+
$ListTypes = 'Sender', 'Url', 'FileHash', 'IP'
13+
14+
try {
15+
foreach ($ListType in $ListTypes) {
16+
$Entries = New-ExoRequest -tenantid $domainName -cmdlet 'Get-TenantAllowBlockListItems' -cmdParams @{ ListType = $ListType }
17+
foreach ($Entry in $Entries) {
18+
$CleanEntry = $Entry | Select-Object -ExcludeProperty *'@data.type'*, *'(DateTime])'*
19+
$CleanEntry | Add-Member -MemberType NoteProperty -Name Tenant -Value $domainName -Force
20+
$CleanEntry | Add-Member -MemberType NoteProperty -Name ListType -Value $ListType -Force
21+
$Entity = @{
22+
Entry = [string]($CleanEntry | ConvertTo-Json -Depth 10 -Compress)
23+
RowKey = [string](New-Guid).Guid
24+
PartitionKey = 'TenantAllowBlockList'
25+
Tenant = [string]$domainName
26+
}
27+
Add-CIPPAzDataTableEntity @Table -Entity $Entity -Force | Out-Null
28+
}
29+
}
30+
} catch {
31+
$ErrorEntry = [pscustomobject]@{
32+
Tenant = $domainName
33+
ListType = 'Error'
34+
Identity = 'Error'
35+
DisplayName = "Could not retrieve tenant allow/block list: $($_.Exception.Message)"
36+
Timestamp = (Get-Date).ToString('s')
37+
}
38+
$Entity = @{
39+
Entry = [string]($ErrorEntry | ConvertTo-Json -Depth 10 -Compress)
40+
RowKey = [string](New-Guid).Guid
41+
PartitionKey = 'TenantAllowBlockList'
42+
Tenant = [string]$domainName
43+
}
44+
Add-CIPPAzDataTableEntity @Table -Entity $Entity -Force | Out-Null
45+
}
46+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Spamfilter/Invoke-AddTenantAllowBlockList.ps1

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-AddTenantAllowBlockList {
1+
function Invoke-AddTenantAllowBlockList {
22
<#
33
.FUNCTIONALITY
44
Entrypoint
@@ -9,14 +9,24 @@ Function Invoke-AddTenantAllowBlockList {
99
param($Request, $TriggerMetadata)
1010

1111
$APIName = $Request.Params.CIPPEndpoint
12+
$Headers = $Request.Headers
13+
1214
$BlockListObject = $Request.Body
13-
if ($Request.Body.tenantId -eq 'AllTenants') { $Tenants = (Get-Tenants).defaultDomainName } else { $Tenants = @($Request.body.tenantId) }
15+
$TenantID = $Request.Body.tenantID.value ?? $Request.Body.tenantID
16+
17+
if ($TenantID -eq 'AllTenants') {
18+
$Tenants = (Get-Tenants).defaultDomainName
19+
} elseif ($TenantID -is [array]) {
20+
$Tenants = $TenantID
21+
} else {
22+
$Tenants = @($TenantID)
23+
}
1424
$Results = [System.Collections.Generic.List[string]]::new()
1525
$Entries = @()
1626
if ($BlockListObject.entries -is [array]) {
1727
$Entries = $BlockListObject.entries
1828
} else {
19-
$Entries = @($BlockListObject.entries -split "[,;]" | Where-Object { $_ -ne "" } | ForEach-Object { $_.Trim() })
29+
$Entries = @($BlockListObject.entries -split '[,;]' | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | ForEach-Object { $_.Trim() })
2030
}
2131
foreach ($Tenant in $Tenants) {
2232
try {
@@ -38,19 +48,20 @@ Function Invoke-AddTenantAllowBlockList {
3848
}
3949

4050
New-ExoRequest @ExoRequest
41-
42-
$results.add("Successfully added $($BlockListObject.Entries) as type $($BlockListObject.ListType) to the $($BlockListObject.listMethod) list for $tenant")
43-
Write-LogMessage -headers $Request.Headers -API $APIName -tenant $Tenant -message $result -Sev 'Info'
51+
$Result = "Successfully added $($BlockListObject.Entries) as type $($BlockListObject.ListType) to the $($BlockListObject.listMethod) list for $tenant"
52+
$Results.Add($Result)
53+
Write-LogMessage -headers $Headers -API $APIName -tenant $Tenant -message $Result -Sev 'Info'
4454
} catch {
45-
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
46-
$results.add("Failed to create blocklist. Error: $ErrorMessage")
47-
Write-LogMessage -headers $Request.Headers -API $APIName -tenant $Tenant -message $result -Sev 'Error'
55+
$ErrorMessage = Get-CippException -Exception $_
56+
$Result = "Failed to create blocklist. Error: $($ErrorMessage.NormalizedError)"
57+
$Results.Add($Result)
58+
Write-LogMessage -headers $Headers -API $APIName -tenant $Tenant -message $Result -Sev 'Error' -LogData $ErrorMessage
4859
}
4960
}
5061
return ([HttpResponseContext]@{
5162
StatusCode = [HttpStatusCode]::OK
5263
Body = @{
53-
'Results' = $results
64+
'Results' = $Results
5465
'Request' = $ExoRequest
5566
}
5667
})
Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-ListTenantAllowBlockList {
1+
function Invoke-ListTenantAllowBlockList {
22
<#
33
.FUNCTIONALITY
44
Entrypoint
@@ -11,21 +11,74 @@ Function Invoke-ListTenantAllowBlockList {
1111
$TenantFilter = $Request.Query.tenantFilter
1212
$ListTypes = 'Sender', 'Url', 'FileHash', 'IP'
1313
try {
14-
$Results = $ListTypes | ForEach-Object -Parallel {
15-
Import-Module CIPPCore
16-
$TempResults = New-ExoRequest -tenantid $using:TenantFilter -cmdlet 'Get-TenantAllowBlockListItems' -cmdParams @{ListType = $_ }
17-
$TempResults | Add-Member -MemberType NoteProperty -Name ListType -Value $_
18-
$TempResults | Select-Object -ExcludeProperty *'@data.type'*, *'(DateTime])'*
19-
} -ThrottleLimit 5
20-
14+
if ($TenantFilter -ne 'AllTenants') {
15+
$Results = $ListTypes | ForEach-Object -Parallel {
16+
Import-Module CIPPCore
17+
$TempResults = New-ExoRequest -tenantid $using:TenantFilter -cmdlet 'Get-TenantAllowBlockListItems' -cmdParams @{ ListType = $_ }
18+
$TempResults | Add-Member -MemberType NoteProperty -Name ListType -Value $_ -Force
19+
$TempResults | Add-Member -MemberType NoteProperty -Name Tenant -Value $using:TenantFilter -Force
20+
$TempResults | Select-Object -ExcludeProperty *'@data.type'*, *'(DateTime])'*
21+
} -ThrottleLimit 5
22+
$Metadata = [PSCustomObject]@{}
23+
} else {
24+
$Table = Get-CIPPTable -TableName 'cacheTenantAllowBlockList'
25+
$PartitionKey = 'TenantAllowBlockList'
26+
$Filter = "PartitionKey eq '$PartitionKey'"
27+
$Rows = Get-CIPPAzDataTableEntity @Table -filter $Filter | Where-Object -Property Timestamp -GT (Get-Date).AddMinutes(-60)
28+
$QueueReference = '{0}-{1}' -f $TenantFilter, $PartitionKey
29+
$RunningQueue = Invoke-ListCippQueue -Reference $QueueReference | Where-Object { $_.Status -notmatch 'Completed' -and $_.Status -notmatch 'Failed' }
30+
if ($RunningQueue) {
31+
$Metadata = [PSCustomObject]@{
32+
QueueMessage = 'Still loading data for all tenants. Please check back in a few more minutes'
33+
QueueId = $RunningQueue.RowKey
34+
}
35+
$Results = @()
36+
} elseif (!$Rows -and !$RunningQueue) {
37+
$TenantList = Get-Tenants -IncludeErrors
38+
$Queue = New-CippQueueEntry -Name 'Tenant Allow/Block List - All Tenants' -Link '/tenant/administration/allow-block-list?customerId=AllTenants' -Reference $QueueReference -TotalTasks ($TenantList | Measure-Object).Count
39+
$Metadata = [PSCustomObject]@{
40+
QueueMessage = 'Loading data for all tenants. Please check back in a few minutes'
41+
QueueId = $Queue.RowKey
42+
}
43+
$InputObject = [PSCustomObject]@{
44+
OrchestratorName = 'TenantAllowBlockListOrchestrator'
45+
QueueFunction = @{
46+
FunctionName = 'GetTenants'
47+
QueueId = $Queue.RowKey
48+
TenantParams = @{
49+
IncludeErrors = $true
50+
}
51+
DurableName = 'ListTenantAllowBlockListAllTenants'
52+
}
53+
SkipLog = $true
54+
}
55+
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5 -Compress) | Out-Null
56+
$Results = @()
57+
} else {
58+
$Metadata = [PSCustomObject]@{
59+
QueueId = $RunningQueue.RowKey ?? $null
60+
}
61+
$Results = foreach ($Row in $Rows) {
62+
$Row.Entry | ConvertFrom-Json
63+
}
64+
}
65+
}
2166
$StatusCode = [HttpStatusCode]::OK
2267
} catch {
2368
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
2469
$StatusCode = [HttpStatusCode]::Forbidden
2570
$Results = $ErrorMessage
2671
}
27-
return [HttpResponseContext]@{
28-
StatusCode = $StatusCode
29-
Body = @($Results)
72+
73+
if (!$Body) {
74+
$Body = [PSCustomObject]@{
75+
Results = @($Results)
76+
Metadata = $Metadata
3077
}
78+
}
79+
80+
return [HttpResponseContext]@{
81+
StatusCode = $StatusCode
82+
Body = $Body
83+
}
3184
}

Modules/CIPPCore/Public/GraphHelper/Write-AlertTrace.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ function Write-AlertTrace {
66
param(
77
$cmdletName,
88
$data,
9-
$tenantFilter
9+
$tenantFilter,
10+
[string]$PartitionKey = (Get-Date -UFormat '%Y%m%d').ToString()
1011
)
1112
$Table = Get-CIPPTable -tablename AlertLastRun
12-
$PartitionKey = (Get-Date -UFormat '%Y%m%d').ToString()
1313
#Get current row and compare the $logData object. If it's the same, don't write it.
1414
$Row = Get-CIPPAzDataTableEntity @table -Filter "RowKey eq '$($tenantFilter)-$($cmdletName)' and PartitionKey eq '$PartitionKey'"
1515
try {

Modules/CIPPCore/Public/PermissionsTranslator.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5328,12 +5328,12 @@
53285328
"value": "AllSites.FullControl"
53295329
},
53305330
{
5331-
"description": "Allows to read the LAPs passwords.",
5332-
"displayName": "Manage LAPs passwords",
5331+
"description": "Allows to read the LAPS passwords.",
5332+
"displayName": "Manage LAPS passwords",
53335333
"id": "280b3b69-0437-44b1-bc20-3b2fca1ee3e9",
53345334
"Origin": "Delegated",
5335-
"userConsentDescription": "Allows to read the LAPs passwords.",
5336-
"userConsentDisplayName": "Manage LAPs passwords",
5335+
"userConsentDescription": "Allows to read the LAPS passwords.",
5336+
"userConsentDisplayName": "Manage LAPS passwords",
53375337
"value": "DeviceLocalCredential.Read.All"
53385338
},
53395339
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function Invoke-CIPPStandardAutopilotProfile {
5959
if ($Settings.NotLocalAdmin -eq $true) { $userType = 'Standard' } else { $userType = 'Administrator' }
6060
if ($Settings.SelfDeployingMode -eq $true) {
6161
$DeploymentMode = 'shared'
62-
$Setings.AllowWhiteGlove = $false
62+
$Settings.AllowWhiteGlove = $false
6363
} else {
6464
$DeploymentMode = 'singleUser'
6565
}

0 commit comments

Comments
 (0)