mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-19 17:31:39 +02: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 (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/rs/xid"
|
"github.com/rs/xid"
|
||||||
@ -175,8 +176,13 @@ func (h *Policies) savePolicy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if r.Ports != nil && len(*r.Ports) != 0 {
|
if r.Ports != nil && len(*r.Ports) != 0 {
|
||||||
ports := *r.Ports
|
for _, v := range *r.Ports {
|
||||||
pr.Ports = 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
|
// validate policy object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user