Skip to content

Commit

Permalink
Merge pull request #1110 from OwenIbarra/dev
Browse files Browse the repository at this point in the history
error handling, some typos
  • Loading branch information
JohnDuprey authored Sep 17, 2024
2 parents 8e60c31 + 5c65157 commit 51bda30
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function Invoke-CippWebhookProcessing {

$ActionList = ($data.CIPPAction | ConvertFrom-Json -ErrorAction SilentlyContinue).value
$ActionResults = foreach ($action in $ActionList) {
Write-Host "this is our action: $($action | ConvertTo-Json -Depth 15 -Compress))"
Write-Host "this is our action: $($action | ConvertTo-Json -Depth 15 -Compress)"
switch ($action) {
'disableUser' {
Set-CIPPSignInState -TenantFilter $TenantFilter -User $data.UserId -AccountEnabled $false -APIName 'Alert Engine' -ExecutingUser 'Alert Engine'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ Function Invoke-RemoveWebhookAlert {

$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$Table = get-cipptable -TableName 'SchedulerConfig'

try {
$WebhookTable = Get-CIPPTable -TableName SchedulerConfig
$WebhookTable = Get-CIPPTable -TableName 'SchedulerConfig'
$WebhookRow = Get-CIPPAzDataTableEntity @WebhookTable -Filter "PartitionKey eq 'WebhookAlert'" | Where-Object -Property Tenant -EQ $Request.query.TenantFilter
Write-Host "The webhook count is $($WebhookRow.count)"
if ($WebhookRow.count -gt 1) {
Expand All @@ -34,7 +33,7 @@ Function Invoke-RemoveWebhookAlert {
}
Remove-AzDataTableEntity @Table -Entity $CompleteObject -ErrorAction SilentlyContinue | Out-Null
} catch {
#
Write-LogMessage -user $Request.headers.'x-ms-client-principal' -API $APIName -message "Failed to remove webhook for AllTenants. $($_.Exception.Message)" -Sev 'Error'
}
} else {
$Tenants = $Request.query.TenantFilter
Expand All @@ -53,10 +52,9 @@ Function Invoke-RemoveWebhookAlert {
$body = [pscustomobject]@{'Results' = "Failed to remove webhook alert: $($_.Exception.Message)" }
}


# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function New-CIPPGraphSubscription {
[switch]$PartnerCenter
)
$CIPPID = (New-Guid).GUID
$WebhookTable = Get-CIPPTable -TableName webhookTable
$WebhookTable = Get-CIPPTable -TableName 'webhookTable'

try {
if ($auditLogAPI) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Remove-CIPPGraphSubscription {
}
}
} else {
$WebhookTable = Get-CIPPTable -TableName webhookTable
$WebhookTable = Get-CIPPTable -TableName 'webhookTable'
if ($type -eq 'AuditLog') {
$WebhookRow = Get-CIPPAzDataTableEntity @WebhookTable | Where-Object { $_.PartitionKey -eq $TenantFilter -and $_.Resource -eq $EventType }
} else {
Expand Down
6 changes: 3 additions & 3 deletions Modules/CIPPCore/Public/Webhooks/Test-CIPPAuditLogRules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ function Test-CIPPAuditLogRules {
Write-Information "Logs to process: $LogCount"
$Results.TotalLogs = $LogCount
if ($LogCount -gt 0) {
$PreProccessedData = $Data | Select-Object *, CIPPAction, CIPPClause, CIPPGeoLocation, CIPPBadRepIP, CIPPHostedIP, CIPPIPDetected, CIPPLocationInfo, CIPPExtendedProperties, CIPPDeviceProperties, CIPPParameters, CIPPModifiedProperties -ErrorAction SilentlyContinue
$PreProcessedData = $Data | Select-Object *, CIPPAction, CIPPClause, CIPPGeoLocation, CIPPBadRepIP, CIPPHostedIP, CIPPIPDetected, CIPPLocationInfo, CIPPExtendedProperties, CIPPDeviceProperties, CIPPParameters, CIPPModifiedProperties -ErrorAction SilentlyContinue
$LocationTable = Get-CIPPTable -TableName 'knownlocationdb'
$ProcessedData = foreach ($Data in $PreProccessedData) {
$ProcessedData = foreach ($Data in $PreProcessedData) {
try {
if ($Data.ExtendedProperties) {
$Data.CIPPExtendedProperties = ($Data.ExtendedProperties | ConvertTo-Json)
Expand Down Expand Up @@ -105,7 +105,7 @@ function Test-CIPPAuditLogRules {
try {
$Location = Get-CIPPGeoIPLocation -IP $Data.clientip
} catch {
Write-Information "Unable to get IP location for $($Data.clientip): $($_.Exception.Messge)"
Write-Information "Unable to get IP location for $($Data.clientip): $($_.Exception.Message)"
}
$Country = if ($Location.CountryCode) { $Location.CountryCode } else { 'Unknown' }
$City = if ($Location.City) { $Location.City } else { 'Unknown' }
Expand Down

0 comments on commit 51bda30

Please sign in to comment.