mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
add uuid check before insering into url
This commit is contained in:
parent
f3fe6eb1c5
commit
f1122a019c
13 changed files with 162 additions and 12 deletions
10
api/misc.go
10
api/misc.go
|
@ -3,12 +3,15 @@ package api
|
|||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
var isUUID = regexp.MustCompile("^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$")
|
||||
|
||||
func randStringBytesRmndr(length int) string {
|
||||
b := make([]byte, length)
|
||||
for i := range b {
|
||||
|
@ -41,3 +44,10 @@ func checkAuthTokenFormat(authToken string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkUUIDFormat(data string) error {
|
||||
if !isUUID.MatchString(data) {
|
||||
return fmt.Errorf("UUID is not in the valid format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue