mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-05-24 00:24:06 +03:00
fix: add basic server-side input validation (#435)
This mitigates possible path traversal attacks by using e.g. "../user" as a user name.
This commit is contained in:
parent
a06bce88e0
commit
13a4c05ff5
3 changed files with 58 additions and 14 deletions
|
@ -2,6 +2,7 @@ package model
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
@ -18,7 +19,13 @@ func (host WakeOnLanHost) ResolveResourceName() (string, error) {
|
|||
return "", errors.New("mac Address is Empty")
|
||||
}
|
||||
resourceName = strings.ToUpper(resourceName)
|
||||
return strings.ReplaceAll(resourceName, ":", "-"), nil
|
||||
resourceName = strings.ReplaceAll(resourceName, ":", "-")
|
||||
|
||||
if _, err := net.ParseMAC(resourceName); err != nil {
|
||||
return "", errors.New("invalid mac address")
|
||||
}
|
||||
|
||||
return resourceName, nil
|
||||
}
|
||||
|
||||
const WakeOnLanHostCollectionName = "wake_on_lan_hosts"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue