Skip to content

Commit

Permalink
Merge pull request #20 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
pull[bot] authored Jan 24, 2025
2 parents 270eafc + bb9bf14 commit fe5932f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

function Invoke-ExecAzBobbyTables {
<#
.SYNOPSIS
Execute a AzBobbyTables function
.DESCRIPTION
This function is used to interact with Azure Tables. This is advanced functionality used for external integrations or SuperAdmin functionality.
.FUNCTIONALITY
Entrypoint
.ROLE
CIPP.SuperAdmin.ReadWrite
#>
[CmdletBinding()]
param($Request, $TriggerMetadata)

$AllowList = @(
'Add-AzDataTableEntity'
'Update-AzDataTableEntity'
'Get-AzDataTableEntity'
'Get-AzDataTable'
'New-AzDataTable'
'Remove-AzDataTableEntity'
'Remove-AzDataTable'
)

$Function = $Request.Body.FunctionName
$Params = if ($Request.Body.Parameters) {
$Request.Body.Parameters | ConvertTo-Json -Compress -ErrorAction Stop | ConvertFrom-Json -AsHashtable
} else {
@{}
}

if ($Function -in $AllowList) {
if ($Function -eq 'Get-AzDataTable') {
$Context = New-AzDataTableContext -ConnectionString $env:AzureWebJobsStorage
} else {
$Context = New-AzDataTableContext -ConnectionString $env:AzureWebJobsStorage -TableName $Request.Body.TableName
}
try {
$Results = & $Function -Context $Context @Params
if (!$Results) {
$Results = "Function $Function executed successfully"
}
$StatusCode = [HttpStatusCode]::OK
} catch {
$Results = $_.Exception.Message
$StatusCode = [HttpStatusCode]::InternalServerError
}
} else {
$Results = "Function $Function not found or not allowed"
$StatusCode = [HttpStatusCode]::NotFound
}

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = $StatusCode
Body = $Results
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Function Invoke-ExecIncidentsList {
if (!$body) {
$StatusCode = [HttpStatusCode]::OK
$body = [PSCustomObject]@{
MSResults = ($GraphRequest | Where-Object -Property id -NE $null)
Results = @($GraphRequest | Where-Object -Property id -NE $null)
}
}
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Function Invoke-AddStandardsTemplate {

}
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created CA Template $($Request.body.name) with GUID $GUID" -Sev 'Debug'
$body = [pscustomobject]@{'Results' = 'Successfully added template' }
$body = [pscustomobject]@{'Results' = 'Successfully added template'; id = $GUID }

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
Expand Down
3 changes: 2 additions & 1 deletion Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function Get-CIPPStandards {
$Table = Get-CippTable -tablename 'templates'
$Filter = "PartitionKey eq 'StandardsTemplateV2'"
$Templates = (Get-CIPPAzDataTableEntity @Table -Filter $Filter | Sort-Object TimeStamp).JSON | ForEach-Object {
ConvertFrom-Json -InputObject $_ -ErrorAction SilentlyContinue
#in the string $_, replace the word 'action' by the word 'Action'.
$_ -replace 'Action', 'action' | ConvertFrom-Json -InputObject $_ -ErrorAction SilentlyContinue
} | Where-Object {
$_.GUID -like $TemplateId -and $_.runManually -eq $runManually
}
Expand Down

0 comments on commit fe5932f

Please sign in to comment.