Skip to content

Commit c6e1510

Browse files
authored
Merge pull request #473 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents a3e1248 + 7bbcb33 commit c6e1510

File tree

440 files changed

+1794
-1060
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

440 files changed

+1794
-1060
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FUNCTIONS_WORKER_RUNTIME='powershell'
2+
FUNCTIONS_WORKER_RUNTIME_VERSION='7.4'
3+
AzureWebJobsStorage='DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNoBnZf6KgBVU4=;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1;'
4+
DEV_SKIP_BPA_TIMER='true'
5+
DEV_SKIP_DOMAIN_TIMER='true'
6+
FUNCTIONS_EXTENSION_VERSION='4'
7+
NonLocalHostAzurite='true'

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# To enable ssh & remote debugging on app service change the base image to the one below
22
# FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7.2-appservice
3-
FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7.2
3+
FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7.4
44
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
55
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
66

7-
COPY . /home/site/wwwroot
7+
COPY . /home/site/wwwroot
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
function Get-CIPPAlertRestrictedUsers {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
#>
6+
[CmdletBinding()]
7+
param (
8+
[Parameter(Mandatory = $false)]
9+
[Alias('input')]
10+
$InputValue,
11+
$TenantFilter
12+
)
13+
14+
try {
15+
$BlockedUsers = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-BlockedSenderAddress'
16+
17+
if ($BlockedUsers) {
18+
$AlertData = foreach ($User in $BlockedUsers) {
19+
# Parse the reason to make it more readable
20+
$ReasonParts = $User.Reason -split ';'
21+
$LimitType = ($ReasonParts | Where-Object { $_ -like 'ExceedingLimitType=*' }) -replace 'ExceedingLimitType=', ''
22+
$InternalCount = ($ReasonParts | Where-Object { $_ -like 'InternalRecipientCountToday=*' }) -replace 'InternalRecipientCountToday=', ''
23+
$ExternalCount = ($ReasonParts | Where-Object { $_ -like 'ExternalRecipientCountToday=*' }) -replace 'ExternalRecipientCountToday=', ''
24+
25+
[PSCustomObject]@{
26+
SenderAddress = $User.SenderAddress
27+
Message = "User $($User.SenderAddress) is restricted from sending email. Block type: $($LimitType ?? 'Unknown'). Created: $($User.CreatedDatetime)"
28+
BlockType = if ($LimitType) { "$LimitType recipient limit exceeded" } else { 'Email sending limit exceeded' }
29+
TemporaryBlock = $User.TemporaryBlock
30+
InternalCount = $InternalCount
31+
ExternalCount = $ExternalCount
32+
CreatedDatetime = $User.CreatedDatetime
33+
Reason = $User.Reason
34+
}
35+
}
36+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
37+
}
38+
} catch {
39+
Write-AlertMessage -tenant $($TenantFilter) -message "Could not get restricted users for $($TenantFilter): $(Get-NormalizedError -message $_.Exception.message)"
40+
}
41+
}

Modules/CIPPCore/Public/Authentication/Test-CIPPAccess.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function Test-CIPPAccess {
7979
}
8080
if ($Request.Params.CIPPEndpoint -eq 'me') {
8181
$Permissions = Get-CippAllowedPermissions -UserRoles $CustomRoles
82-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
82+
return ([HttpResponseContext]@{
8383
StatusCode = [HttpStatusCode]::OK
8484
Body = (
8585
@{
@@ -90,7 +90,6 @@ function Test-CIPPAccess {
9090
'permissions' = $Permissions
9191
} | ConvertTo-Json -Depth 5)
9292
})
93-
return
9493
}
9594

9695
} else {
@@ -107,7 +106,7 @@ function Test-CIPPAccess {
107106
if ($Request.Params.CIPPEndpoint -eq 'me') {
108107

109108
if (!$User.userRoles) {
110-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
109+
return ([HttpResponseContext]@{
111110
StatusCode = [HttpStatusCode]::OK
112111
Body = (
113112
@{
@@ -118,15 +117,14 @@ function Test-CIPPAccess {
118117
}
119118

120119
$Permissions = Get-CippAllowedPermissions -UserRoles $User.userRoles
121-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
120+
return ([HttpResponseContext]@{
122121
StatusCode = [HttpStatusCode]::OK
123122
Body = (
124123
@{
125124
'clientPrincipal' = $User
126125
'permissions' = $Permissions
127126
} | ConvertTo-Json -Depth 5)
128127
})
129-
return
130128
}
131129

132130
if ($User.userRoles -contains 'admin' -or $User.userRoles -contains 'superadmin') {

Modules/CIPPCore/Public/CippQueue/Invoke-ListCippQueue.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function Invoke-ListCippQueue {
7474
}
7575

7676
if ($request) {
77-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
77+
return ([HttpResponseContext]@{
7878
StatusCode = [HttpStatusCode]::OK
7979
Body = @($QueueData)
8080
})

Modules/CIPPCore/Public/CippQueue/Invoke-RemoveCippQueue.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ function Invoke-RemoveCippQueue {
99

1010
$APIName = $Request.Params.CIPPEndpoint
1111
$Headers = $Request.Headers
12-
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
12+
1313

1414
$CippQueue = Get-CippTable -TableName 'CippQueue'
1515
Clear-AzDataTable @CippQueue
1616
$CippQueueTasks = Get-CippTable -TableName 'CippQueueTasks'
1717
Clear-AzDataTable @CippQueueTasks
1818

19-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
19+
return ([HttpResponseContext]@{
2020
StatusCode = [HttpStatusCode]::OK
2121
Body = @{Results = @('History cleared') }
2222
})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Invoke-ExecAddAlert {
1212

1313
$APIName = $Request.Params.CIPPEndpoint
1414
$Headers = $Request.Headers
15-
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
15+
1616

1717
$Severity = 'Alert'
1818

@@ -70,7 +70,7 @@ function Invoke-ExecAddAlert {
7070
Write-LogMessage -headers $Headers -API 'Alerts' -message $Request.Body.text -Sev $Severity
7171
'Successfully generated alert.'
7272
}
73-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
73+
return ([HttpResponseContext]@{
7474
StatusCode = [HttpStatusCode]::OK
7575
Body = $Result
7676
})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Invoke-ExecAzBobbyTables {
1515

1616
$APIName = $Request.Params.CIPPEndpoint
1717
$Headers = $Request.Headers
18-
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
18+
1919

2020
$AllowList = @(
2121
'Add-AzDataTableEntity'
@@ -57,7 +57,7 @@ function Invoke-ExecAzBobbyTables {
5757
$StatusCode = [HttpStatusCode]::NotFound
5858
}
5959

60-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
60+
return ([HttpResponseContext]@{
6161
StatusCode = $StatusCode
6262
Body = @($Results)
6363
})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ function Invoke-ExecCPVRefresh {
1414

1515
$APIName = $Request.Params.CIPPEndpoint
1616
$Headers = $Request.Headers
17-
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
17+
1818

1919
$InstanceId = Start-UpdatePermissionsOrchestrator
2020

21-
Push-OutputBinding -Name Response -Value @{
21+
return @{
2222
StatusCode = [System.Net.HttpStatusCode]::OK
2323
Body = @{
2424
Results = 'CPV Refresh has been triggered'

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function Invoke-ExecCippFunction {
1414

1515
$APIName = $Request.Params.CIPPEndpoint
1616
$Headers = $Request.Headers
17-
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
17+
1818

1919
$BlockList = @(
2020
'Get-GraphToken'
@@ -45,7 +45,7 @@ function Invoke-ExecCippFunction {
4545
$StatusCode = [HttpStatusCode]::NotFound
4646
}
4747

48-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
48+
return ([HttpResponseContext]@{
4949
StatusCode = $StatusCode
5050
Body = $Results
5151
})

0 commit comments

Comments
 (0)