forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'KelvinTegelaar:master' into master
- Loading branch information
Showing
962 changed files
with
29,774 additions
and
36,844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
insert_final_newline = true | ||
|
||
[*.{ps1, psd1, psm1}] | ||
indent_size = 4 | ||
end_of_line = crlf | ||
trim_trailing_whitespace = true | ||
|
||
[*.json] | ||
indent_size = 2 | ||
end_of_line = crlf | ||
trim_trailing_whitespace = true | ||
|
||
[*.{md, txt}] | ||
end_of_line = crlf | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 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 - cippacnqv | ||
|
||
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 | ||
permissions: | ||
id-token: write #This is required for requesting the JWT | ||
|
||
steps: | ||
- name: 'Checkout GitHub Action' | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Azure | ||
uses: azure/login@v1 | ||
with: | ||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_6085081ED1124B799258E9FF743FF4B9 }} | ||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_9BDB2DDBFAFA4BC19C20A58B204BFAF3 }} | ||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_02B5224812794971B05EDD557AF2B867 }} | ||
|
||
- name: 'Run Azure Functions Action' | ||
uses: Azure/functions-action@v1 | ||
id: fa | ||
with: | ||
app-name: 'cippacnqv' | ||
slot-name: 'Production' | ||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 - cippz6s4d | ||
|
||
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: 'cippz6s4d' | ||
slot-name: 'Production' | ||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }} | ||
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_D27E7CF0887F4E4591F3957CCA96F0FD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
using namespace System.Net | ||
|
||
param($Request, $TriggerMetadata) | ||
if ($CurrentlyRunning) { | ||
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' } | ||
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info | ||
|
||
if ($Request.Query.TenantFilter) { | ||
$TenantList = @($Request.Query.TenantFilter) | ||
$Name = "Best Practice Analyser ($($Request.Query.TenantFilter))" | ||
} else { | ||
$InputObject = @{ | ||
TenantFilter = $Request.Query.TenantFilter | ||
$TenantList = Get-Tenants | ||
$Name = 'Best Practice Analyser (All Tenants)' | ||
} | ||
|
||
$BPATemplateTable = Get-CippTable -tablename 'templates' | ||
$Filter = "PartitionKey eq 'BPATemplate'" | ||
$Templates = ((Get-CIPPAzDataTableEntity @BPATemplateTable -Filter $Filter).JSON | ConvertFrom-Json).Name | ||
|
||
$BPAReports = foreach ($Tenant in $TenantList) { | ||
foreach ($Template in $Templates) { | ||
[PSCustomObject]@{ | ||
FunctionName = 'BPACollectData' | ||
Tenant = $Tenant.defaultDomainName | ||
Template = $Template | ||
QueueName = '{0} - {1}' -f $Template, $Tenant.defaultDomainName | ||
} | ||
} | ||
$InstanceId = Start-NewOrchestration -FunctionName 'BestPracticeAnalyser_Orchestration' -InputObject $InputObject | ||
Write-Host "Started orchestration with ID = '$InstanceId'" | ||
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId | ||
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Started retrieving best practice information' -sev Info | ||
$Results = [pscustomobject]@{'Results' = 'Started running analysis' } | ||
} | ||
Write-Host ($Orchestrator | ConvertTo-Json) | ||
|
||
$Queue = New-CippQueueEntry -Name $Name -TotalTasks ($BPAReports | Measure-Object).Count | ||
$BPAReports = $BPAReports | Select-Object *, @{Name = 'QueueId'; Expression = { $Queue.RowKey } } | ||
$InputObject = [PSCustomObject]@{ | ||
Batch = @($BPAReports) | ||
OrchestratorName = 'BPAOrchestrator' | ||
SkipLog = $true | ||
} | ||
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5) | ||
|
||
$Results = [pscustomobject]@{'Results' = 'BPA started' } | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $results | ||
Body = $Results | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
param($Timer) | ||
|
||
if ($env:DEV_SKIP_BPA_TIMER) { | ||
if ($env:DEV_SKIP_BPA_TIMER) { | ||
Write-Host 'Skipping BPA timer' | ||
exit 0 | ||
exit 0 | ||
} | ||
|
||
try { | ||
$CurrentlyRunning = Get-Item 'Cache_BestPracticeAnalyser\CurrentlyRunning.txt' -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24) | ||
if ($CurrentlyRunning) { | ||
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' } | ||
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info | ||
} | ||
else { | ||
$InstanceId = Start-NewOrchestration -FunctionName 'BestPracticeAnalyser_Orchestration' | ||
Write-Host "Started orchestration with ID = '$InstanceId'" | ||
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Timer -InstanceId $InstanceId | ||
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Started retrieving best practice information' -sev Info | ||
$Results = [pscustomobject]@{'Results' = 'Started running analysis' } | ||
$TenantList = Get-Tenants | ||
|
||
$BPATemplateTable = Get-CippTable -tablename 'templates' | ||
$Filter = "PartitionKey eq 'BPATemplate'" | ||
$Templates = ((Get-CIPPAzDataTableEntity @BPATemplateTable -Filter $Filter).JSON | ConvertFrom-Json).Name | ||
|
||
|
||
$BPAReports = foreach ($Tenant in $TenantList) { | ||
foreach ($Template in $Templates) { | ||
[PSCustomObject]@{ | ||
FunctionName = 'BPACollectData' | ||
Tenant = $Tenant.defaultDomainName | ||
Template = $Template | ||
QueueName = '{0} - {1}' -f $Template, $Tenant.defaultDomainName | ||
} | ||
} | ||
Write-Host ($Orchestrator | ConvertTo-Json) | ||
} | ||
catch { Write-Host "BestPracticeAnalyser_OrchestratorStarterTimer Exception $($_.Exception.Message)" } | ||
|
||
$Queue = New-CippQueueEntry -Name 'Best Practice Analyser' -TotalTasks ($BPAReports | Measure-Object).Count | ||
$BPAReports = $BPAReports | Select-Object *, @{Name = 'QueueId'; Expression = { $Queue.RowKey } } | ||
$InputObject = [PSCustomObject]@{ | ||
Batch = @($BPAReports) | ||
OrchestratorName = 'BPAOrchestrator' | ||
SkipLog = $true | ||
} | ||
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5) |
Oops, something went wrong.