From ea36bcf963b4ea8a79735c002653725cdc5132cb Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 14 Oct 2023 20:51:13 +0200 Subject: [PATCH] added length check for api name --- commit_and_push.sh | 7 +++++++ modules/utils/globals.go | 2 ++ socketclients/socketclients.go | 4 ++++ 3 files changed, 13 insertions(+) create mode 100755 commit_and_push.sh diff --git a/commit_and_push.sh b/commit_and_push.sh new file mode 100755 index 0000000..554786f --- /dev/null +++ b/commit_and_push.sh @@ -0,0 +1,7 @@ +git add * + +read -p "Commit message: " commit_message + +git commit -m "$commit_message" + +git push -u origin main \ No newline at end of file diff --git a/modules/utils/globals.go b/modules/utils/globals.go index 04aedbe..1e52169 100644 --- a/modules/utils/globals.go +++ b/modules/utils/globals.go @@ -17,6 +17,8 @@ const ( MaxEquipmentDocumentationTitleLength = "60" MaxEquipmentDocumentationNoteLength = 2000 MaxNoficationTitleLength = "255" + MinUserApiKeyNameLength = 2 + MaxUserApiKeyNameLength = 30 LenHeaderXAuthorization = 36 lenHeaderXAuthorization = "36" diff --git a/socketclients/socketclients.go b/socketclients/socketclients.go index 9a950a3..6e0e260 100644 --- a/socketclients/socketclients.go +++ b/socketclients/socketclients.go @@ -993,6 +993,10 @@ func GetUserApiKeys(userId string) []structs.UserApiKey { } func CreateNewUserApiKey(userId string, apiName string) { + if len(apiName) < utils.MinUserApiKeyNameLength || len(apiName) > utils.MaxUserApiKeyNameLength { + return + } + token, err := rsutils.GenerateSession() if err != nil {