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:
committed by
GitHub
parent
a06bce88e0
commit
13a4c05ff5
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user