Skip to content

Commit 9002cca

Browse files
committed
fix: throw on invalid nextLink url
1 parent a8ac0bd commit 9002cca

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,17 @@ function Get-GraphRequestList {
352352

353353
if (!$QueueThresholdExceeded) {
354354
#nextLink should ONLY be used in direct calls with manual pagination. It should not be used in queueing
355-
if ($ManualPagination.IsPresent -and $nextLink -match '^https://.+') { $GraphRequest.uri = $nextLink }
355+
if ($ManualPagination.IsPresent -and $nextLink -match '^https://.+') {
356+
try {
357+
$ParsedNextLink = [System.Uri]$nextLink
358+
if ($ParsedNextLink.Host -ne 'graph.microsoft.com') {
359+
throw "Invalid nextLink host: $($ParsedNextLink.Host)"
360+
}
361+
} catch {
362+
throw "Invalid nextLink URL: $nextLink"
363+
}
364+
$GraphRequest.uri = $nextLink
365+
}
356366

357367
$GraphRequestResults = New-GraphGetRequest @GraphRequest -Caller $Caller -ErrorAction Stop
358368
$GraphRequestResults = $GraphRequestResults | Select-Object *, @{n = 'Tenant'; e = { $TenantFilter } }, @{n = 'CippStatus'; e = { 'Good' } }

0 commit comments

Comments
 (0)