Bug: tea crashes when using ssh-certificate auth method #527

Open
opened 2023-01-24 15:05:16 +00:00 by tionis · 1 comment

environment

  • tea version used: 0.9.0+9-g6a848cb golang: 1.19.5 go-sdk: v0.15.1-0.20220927025037-8f846bdb9bbe
  • Gitea version used: 1.18.3
  • operating system: Arch Linux

bug

When creating a new login using the ssh-certificate as auth method, tea crashes:

panic: runtime error: index out of range [1] with length 0

goroutine 1 [running]:
code.gitea.io/tea/modules/interact.CreateLogin()
	/home/tionis/tea/modules/interact/login.go:101 +0x1332
code.gitea.io/tea/cmd/login.runLoginAdd(0x55938bde1b20?)
	/home/tionis/tea/cmd/login/add.go:85 +0x305
github.com/urfave/cli/v2.(*Command).Run(0x55938bde1b20, 0xc000518880)
	/home/tionis/tea/vendor/github.com/urfave/cli/v2/command.go:173 +0x6ca
github.com/urfave/cli/v2.(*App).RunAsSubcommand(0xc0001da700, 0xc000518680)
	/home/tionis/tea/vendor/github.com/urfave/cli/v2/app.go:531 +0xd85
github.com/urfave/cli/v2.(*Command).startApp(0x55938bde0140, 0xc000518680)
	/home/tionis/tea/vendor/github.com/urfave/cli/v2/command.go:291 +0x79b
github.com/urfave/cli/v2.(*Command).Run(0x55938b6f5a80?, 0xc00008ad50?)
	/home/tionis/tea/vendor/github.com/urfave/cli/v2/command.go:95 +0xba
github.com/urfave/cli/v2.(*App).RunContext(0xc0001da000, {0x55938b7f6f48?, 0xc00003c118}, {0xc000034180, 0x3, 0x3})
	/home/tionis/tea/vendor/github.com/urfave/cli/v2/app.go:383 +0xfde
github.com/urfave/cli/v2.(*App).Run(...)
	/home/tionis/tea/vendor/github.com/urfave/cli/v2/app.go:252
main.main()
	/home/tionis/tea/main.go:61 +0x27d

My selected ssh-key is an ed25519 key.

### environment - tea version used: 0.9.0+9-g6a848cb golang: 1.19.5 go-sdk: v0.15.1-0.20220927025037-8f846bdb9bbe - Gitea version used: 1.18.3 - operating system: Arch Linux ### bug When creating a new login using the ssh-certificate as auth method, tea crashes: ``` panic: runtime error: index out of range [1] with length 0 goroutine 1 [running]: code.gitea.io/tea/modules/interact.CreateLogin() /home/tionis/tea/modules/interact/login.go:101 +0x1332 code.gitea.io/tea/cmd/login.runLoginAdd(0x55938bde1b20?) /home/tionis/tea/cmd/login/add.go:85 +0x305 github.com/urfave/cli/v2.(*Command).Run(0x55938bde1b20, 0xc000518880) /home/tionis/tea/vendor/github.com/urfave/cli/v2/command.go:173 +0x6ca github.com/urfave/cli/v2.(*App).RunAsSubcommand(0xc0001da700, 0xc000518680) /home/tionis/tea/vendor/github.com/urfave/cli/v2/app.go:531 +0xd85 github.com/urfave/cli/v2.(*Command).startApp(0x55938bde0140, 0xc000518680) /home/tionis/tea/vendor/github.com/urfave/cli/v2/command.go:291 +0x79b github.com/urfave/cli/v2.(*Command).Run(0x55938b6f5a80?, 0xc00008ad50?) /home/tionis/tea/vendor/github.com/urfave/cli/v2/command.go:95 +0xba github.com/urfave/cli/v2.(*App).RunContext(0xc0001da000, {0x55938b7f6f48?, 0xc00003c118}, {0xc000034180, 0x3, 0x3}) /home/tionis/tea/vendor/github.com/urfave/cli/v2/app.go:383 +0xfde github.com/urfave/cli/v2.(*App).Run(...) /home/tionis/tea/vendor/github.com/urfave/cli/v2/app.go:252 main.main() /home/tionis/tea/main.go:61 +0x27d ``` My selected ssh-key is an ed25519 key.
tionis added the
kind/bug
label 2023-01-24 15:05:16 +00:00
tionis changed title from Bug: to Bug: tea crashes when using ssh-certificate auth method 2023-01-24 15:05:33 +00:00

I can confirm, this is caused by:

sshKeyFingerprint = regexp.MustCompile(`(SHA256:.*?)\s`).FindStringSubmatch(sshKey)[1]

There is no guarantee that sshKey will match that expression, so to immediately index it with [1] seems overly enthousiastic.

I can confirm, this is caused by: ```go sshKeyFingerprint = regexp.MustCompile(`(SHA256:.*?)\s`).FindStringSubmatch(sshKey)[1] ``` There is no guarantee that `sshKey` will match that expression, so to immediately index it with `[1]` seems overly enthousiastic.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/tea#527
No description provided.