Skip to content

Commit b16232e

Browse files
committed
add sanity checks to parseRegisterMessage
1 parent 8901e35 commit b16232e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apiserver/slack/slack.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ func (s *slackbot) registrationSlackHandler() {
6767
func parseRegisterMessage(text string) (string, string, error) {
6868
// "register publicKey serial"
6969
parts := strings.Split(text, " ")
70-
publicKey, serial := parts[1], parts[2]
70+
if len(parts) != 3 {
71+
return "", "", fmt.Errorf("parsing register command: not enough params: \"%v\"", text)
72+
}
73+
command, publicKey, serial := parts[0], parts[1], parts[2]
74+
if command != "register" {
75+
return "", "", fmt.Errorf("parsing register command: invalid command: \"%v\"", command)
76+
}
7177
return publicKey, serial, nil
7278
}
7379

0 commit comments

Comments
 (0)