Skip to content

Commit

Permalink
Merge pull request #90 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
kris6673 authored Oct 7, 2024
2 parents 92f598a + c911fe9 commit 11f05e6
Show file tree
Hide file tree
Showing 109 changed files with 2,074 additions and 900 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/dev_cippkkxvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Powershell project to Azure Function App - cippkkxvm

on:
push:
branches:
- dev
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root

jobs:
deploy:
runs-on: windows-latest

steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'cippkkxvm'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_171C3E2B1E2346AAA333905DFCA62F2D }}
30 changes: 30 additions & 0 deletions .github/workflows/dev_cippkwn4s-auditlog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Powershell project to Azure Function App - cippkwn4s-auditlog

on:
push:
branches:
- dev
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root

jobs:
deploy:
runs-on: windows-latest

steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'cippkwn4s-auditlog'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_4CBFBE8BE62240D789C371767B49278E }}
30 changes: 30 additions & 0 deletions .github/workflows/dev_cipplwwww-proc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Powershell project to Azure Function App - cipplwwww-proc

on:
push:
branches:
- dev
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root

jobs:
deploy:
runs-on: windows-latest

steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'cipplwwww-proc'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_B8CE64E970E74E6AB2D6655823D95B1A }}
12 changes: 0 additions & 12 deletions AddAlertSubscription_Queue/function.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
"name": "alertqueue",
"queueName": "alertqueue"
},
{
"type": "queue",
"direction": "out",
"name": "gdapqueue",
"queueName": "gdapqueue"
},
{
"type": "queue",
"direction": "out",
Expand Down
20 changes: 16 additions & 4 deletions CIPPTimers.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@
"Description": "Orchestrator to process user scheduled tasks",
"Cron": "0 */15 * * * *",
"Priority": 1,
"RunOnProcessor": true,
"PreferredProcessor": "usertasks"
},
{
"Command": "Start-CIPPProcessorQueue",
"Description": "Timer to handle user initiated tasks",
"Cron": "0 */15 * * * *",
"Priority": 1,
"RunOnProcessor": true
},
{
"Command": "Start-AuditLogOrchestrator",
"Description": "Orchestrator to process audit logs",
"Cron": "0 */15 * * * *",
"Priority": 2,
"RunOnProcessor": true
"RunOnProcessor": true,
"PreferredProcessor": "auditlog",
"IsSystem": true
},
{
"Command": "Start-WebhookOrchestrator",
Expand All @@ -25,7 +35,8 @@
"Description": "Orchestrator to process standards",
"Cron": "0 0 */4 * * *",
"Priority": 4,
"RunOnProcessor": true
"RunOnProcessor": true,
"PreferredProcessor": "standards"
},
{
"Command": "Start-CIPPGraphSubscriptionCleanupTimer",
Expand Down Expand Up @@ -59,9 +70,10 @@
{
"Command": "Start-CIPPGraphSubscriptionRenewalTimer",
"Description": "Orchestrator to renew Graph subscriptions",
"Cron": "0 10 * * * *",
"Cron": "0 15 * * * *",
"Priority": 8,
"RunOnProcessor": true
"RunOnProcessor": true,
"IsSystem": true
},
{
"Command": "Start-DomainOrchestrator",
Expand Down
10 changes: 0 additions & 10 deletions ExecAlertsListAllTenants/function.json

This file was deleted.

10 changes: 0 additions & 10 deletions ExecIncidentsListAllTenants/function.json

This file was deleted.

10 changes: 0 additions & 10 deletions ExecOffboard_Mailboxpermissions/function.json

This file was deleted.

8 changes: 0 additions & 8 deletions ExecOffboard_Mailboxpermissions/run.ps1

This file was deleted.

10 changes: 0 additions & 10 deletions ExecSchedulerBillingRun/function.json

This file was deleted.

21 changes: 0 additions & 21 deletions ExecSchedulerBillingRun/run.ps1

This file was deleted.

4 changes: 2 additions & 2 deletions Modules/CIPPCore/CIPPCore.psm1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$Public = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -Recurse -ErrorAction SilentlyContinue)
$Private = @(Get-ChildItem -Path $PSScriptRoot\private\*.ps1 -Recurse -ErrorAction SilentlyContinue)
$Public = @(Get-ChildItem -Path (Join-Path $PSScriptRoot "Public\*.ps1") -Recurse -ErrorAction SilentlyContinue)
$Private = @(Get-ChildItem -Path (Join-Path $PSScriptRoot "Private\*.ps1") -Recurse -ErrorAction SilentlyContinue)
$Functions = $Public + $Private
foreach ($import in @($Functions)) {
try {
Expand Down
22 changes: 20 additions & 2 deletions Modules/CIPPCore/Public/Add-CIPPDelegatedPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ function Add-CIPPDelegatedPermission {
$CreateRequest = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/oauth2PermissionGrants' -tenantid $Tenantfilter -body $Createbody -type POST -NoAuthCheck $true
$Results.add("Successfully added permissions for $($svcPrincipalId.displayName)")
} else {
# Cleanup multiple scope entries and patch first id
if (($OldScope.id | Measure-Object).Count -gt 1) {
$OldScopeId = $OldScope.id[0]
$OldScope.id | ForEach-Object {
if ($_ -ne $OldScopeId) {
try {
$null = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/oauth2PermissionGrants/$_" -tenantid $Tenantfilter -type DELETE -NoAuthCheck $true
} catch {
}
}
}
} else {
$OldScopeId = $OldScope.id
}
$compare = Compare-Object -ReferenceObject $OldScope.scope.Split(' ') -DifferenceObject $NewScope.Split(' ')
if (!$compare) {
$Results.add("All delegated permissions exist for $($svcPrincipalId.displayName)")
Expand All @@ -99,8 +113,12 @@ function Add-CIPPDelegatedPermission {
$Patchbody = @{
scope = "$NewScope"
} | ConvertTo-Json -Compress
$null = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/oauth2PermissionGrants/$($OldScope.id)" -tenantid $Tenantfilter -body $Patchbody -type PATCH -NoAuthCheck $true

try {
$null = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/oauth2PermissionGrants/$($OldScopeId)" -tenantid $Tenantfilter -body $Patchbody -type PATCH -NoAuthCheck $true
} catch {
$Results.add("Failed to update permissions for $($svcPrincipalId.displayName): $(Get-NormalizedError -message $_.Exception.Message)")
continue
}
# Added permissions
$Added = ($Compare | Where-Object { $_.SideIndicator -eq '=>' }).InputObject -join ' '
$Removed = ($Compare | Where-Object { $_.SideIndicator -eq '<=' }).InputObject -join ' '
Expand Down
23 changes: 17 additions & 6 deletions Modules/CIPPCore/Public/AdditionalPermissions.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
[
{
"resourceAppId": "00000003-0000-0ff1-ce00-000000000000",
"resourceAccess": [{ "id": "AllProfiles.Manage", "type": "Scope" }]
"resourceAppId": "00000006-0000-0ff1-ce00-000000000000",
"resourceAccess": [
{
"id": "M365AdminPortal.IntegratedApps.ReadWrite",
"type": "Scope"
},
{
"id": "user_impersonation",
"type": "Scope"
}
]
},
{
"resourceAppId": "00000006-0000-0ff1-ce00-000000000000",
"resourceAppId": "00000003-0000-0ff1-ce00-000000000000",
"resourceAccess": [
{ "id": "M365AdminPortal.IntegratedApps.ReadWrite", "type": "Scope" },
{ "id": "user_impersonation", "type": "Scope" }
{
"id": "AllProfiles.Manage",
"type": "Scope"
}
]
}
]
]
6 changes: 4 additions & 2 deletions Modules/CIPPCore/Public/Alerts/Get-CIPPAlertQuotaUsed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function Get-CIPPAlertQuotaUsed {
}
$OverQuota = $AlertData | ForEach-Object {
if ($_.StorageUsedInBytes -eq 0 -or $_.prohibitSendReceiveQuotaInBytes -eq 0) { return }
$PercentLeft = [math]::round(($_.storageUsedInBytes / $_.prohibitSendReceiveQuotaInBytes) * 100)
try {
$PercentLeft = [math]::round(($_.storageUsedInBytes / $_.prohibitSendReceiveQuotaInBytes) * 100)
} catch { $PercentLeft = 100 }
try {
if ([int]$InputValue -gt 0) {
$Value = [int]$InputValue
Expand All @@ -34,4 +36,4 @@ function Get-CIPPAlertQuotaUsed {

}
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $OverQuota
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function Get-CippAuditLogSearchResults {
<#
.SYNOPSIS
Get the results of an audit log search
.DESCRIPTION
Get the results of an audit log search from the Graph API
.PARAMETER TenantFilter
The tenant to filter on.
.PARAMETER QueryId
The ID of the query to get the results for.
#>
param (
[Parameter(Mandatory = $true)]
[string]$TenantFilter,
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
[Alias('id')]
[string]$QueryId
)

process {
New-GraphGetRequest -uri ('https://graph.microsoft.com/beta/security/auditLog/queries/{0}/records?$top=999' -f $QueryId) -AsApp $true -tenantid $TenantFilter
}
}
23 changes: 23 additions & 0 deletions Modules/CIPPCore/Public/AuditLogs/Get-CippAuditLogSearches.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function Get-CippAuditLogSearches {
<#
.SYNOPSIS
Get the available audit log searches
.DESCRIPTION
Query the Graph API for available audit log searches.
.PARAMETER TenantFilter
The tenant to filter on.
#>
param (
[Parameter(Mandatory = $true)]
[string]$TenantFilter,
[Parameter()]
[switch]$ReadyToProcess
)
$Queries = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/security/auditLog/queries' -AsApp $true -tenantid $TenantFilter
if ($ReadyToProcess.IsPresent) {
$AuditLogSearchesTable = Get-CippTable -TableName 'AuditLogSearches'
$PendingQueries = Get-CIPPAzDataTableEntity @AuditLogSearchesTable -Filter "Tenant eq '$TenantFilter' and CippStatus eq 'Pending'"
$Queries = $Queries | Where-Object { $PendingQueries.RowKey -contains $_.id -and $_.status -eq 'succeeded' }
}
return $Queries
}
Loading

0 comments on commit 11f05e6

Please sign in to comment.