From cf753974df8de71dca2d2563d76d87395f233d82 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Sun, 9 Feb 2025 19:23:03 -0500 Subject: [PATCH] ip address validation --- .../HTTP Functions/CIPP/Settings/Invoke-ExecApiClient.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecApiClient.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecApiClient.ps1 index 6b819cf6f721..2d5be60cf1e1 100644 --- a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecApiClient.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecApiClient.ps1 @@ -53,7 +53,13 @@ function Invoke-ExecApiClient { } if ($Request.Body.IpRange.value) { - $IpRange = @($Request.Body.IpRange.value) + $IpRange = [System.Collections.Generic.List[string]]::new() + $regexPattern = '^(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}(?:/\d{1,2})?|(?:[0-9A-Fa-f]{1,4}:){1,7}[0-9A-Fa-f]{1,4}(?:/\d{1,3})?)$' + foreach ($IP in @($Request.Body.IPRange.value)) { + if ($IP -match $regexPattern) { + $IpRange.Add($IP) + } + } } else { $IpRange = @() }