Skip to content

Commit

Permalink
ip address validation
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Feb 10, 2025
1 parent 0256c23 commit cf75397
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
}
Expand Down

0 comments on commit cf75397

Please sign in to comment.