mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-22 08:03:30 +01:00
Fix validation for ACL policy rules ports (#938)
This commit is contained in:
parent
9460c4a91e
commit
803bbe0fff
@ -3,6 +3,7 @@ package http
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/rs/xid"
|
||||
@ -175,8 +176,13 @@ func (h *Policies) savePolicy(
|
||||
}
|
||||
|
||||
if r.Ports != nil && len(*r.Ports) != 0 {
|
||||
ports := *r.Ports
|
||||
pr.Ports = ports[:]
|
||||
for _, v := range *r.Ports {
|
||||
if port, err := strconv.Atoi(v); err != nil || port < 1 || port > 65535 {
|
||||
util.WriteError(status.Errorf(status.InvalidArgument, "valid port value is in 1..65535 range"), w)
|
||||
return
|
||||
}
|
||||
pr.Ports = append(pr.Ports, v)
|
||||
}
|
||||
}
|
||||
|
||||
// validate policy object
|
||||
|
Loading…
Reference in New Issue
Block a user