Skip to content

Commit 176d43b

Browse files
force external uri to be partner center
1 parent 610ec61 commit 176d43b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Modules/CIPPCore/Public/Webhooks/Invoke-CIPPPartnerWebhookProcessing.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ function Invoke-CippPartnerWebhookProcessing {
66

77
try {
88
if ($Data.AuditUri) {
9-
$AuditLog = New-GraphGetRequest -uri $Data.AuditUri -tenantid $env:TenantID -NoAuthCheck $true -scope 'https://api.partnercenter.microsoft.com/.default'
9+
$ParsedAuditUri = $null
10+
if ([System.Uri]::TryCreate([string]$Data.AuditUri, [System.UriKind]::Absolute, [ref]$ParsedAuditUri) -and
11+
$ParsedAuditUri.Scheme -eq 'https' -and
12+
$ParsedAuditUri.Host -eq 'api.partnercenter.microsoft.com') {
13+
$AuditLog = New-GraphGetRequest -uri $ParsedAuditUri.AbsoluteUri -tenantid $env:TenantID -NoAuthCheck $true -scope 'https://api.partnercenter.microsoft.com/.default'
14+
} else {
15+
Write-LogMessage -API 'Webhooks' -message "Partner Center webhook rejected: AuditUri is not a Partner Center API URL ($($Data.AuditUri))" -Sev 'Alert'
16+
return
17+
}
1018
}
1119

1220
switch ($Data.EventName) {

0 commit comments

Comments
 (0)