Skip to content

Commit

Permalink
Fix dupe limit being added during test ip/access rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Badgerati committed Oct 30, 2021
1 parent 72ed353 commit c064a90
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Private/Security.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,23 @@ function Test-PodeIPLimit
# if ip not in rules, it's valid
# (add to active list as always allowed - saves running where search everytime)
if ($null -eq $_rule_ip) {
$active.Add($IP.String, @{
$active[$IP.String] = @{
Rule = @{
Limit = -1
}
})
}

return $true
}

# add ip to active list (ip if not grouped, else the subnet if it's grouped)
$_ip = (Resolve-PodeValue -Check $_rule_ip.Grouped -TrueValue $_rule_ip.IP -FalseValue $IP.String)

$active.Add($_ip, @{
$active[$_ip] = @{
Rule = $_rule_ip
Rate = 1
Expire = $now.AddSeconds($_rule_ip.Seconds)
})
}

# if limit is 0, it's never allowed
return ($_rule_ip -ne 0)
Expand Down Expand Up @@ -161,21 +161,21 @@ function Test-PodeRouteLimit

# if route not in rules, it's valid (add to active list as always allowed)
if ($null -eq $_rule_route) {
$active.Add($Path, @{
$active[$Path] = @{
Rule = @{
Limit = -1
}
})
}

return $true
}

# add route to active list
$active.Add($Path, @{
$active[$Path] = @{
Rule = $_rule_route
Rate = 1
Expire = $now.AddSeconds($_rule_route.Seconds)
})
}

# if limit is 0, it's never allowed
return ($_rule_route -ne 0)
Expand Down Expand Up @@ -241,21 +241,21 @@ function Test-PodeEndpointLimit

# if endpoint not in rules, it's valid (add to active list as always allowed)
if ($null -eq $_rule_endpoint) {
$active.Add($EndpointName, @{
$active[$EndpointName] = @{
Rule = @{
Limit = -1
}
})
}

return $true
}

# add endpoint to active list
$active.Add($EndpointName, @{
$active[$EndpointName] = @{
Rule = $_rule_endpoint
Rate = 1
Expire = $now.AddSeconds($_rule_endpoint.Seconds)
})
}

# if limit is 0, it's never allowed
return ($_rule_endpoint -ne 0)
Expand Down

0 comments on commit c064a90

Please sign in to comment.