diff options
author | Nick Thomas <nick@gitlab.com> | 2021-02-05 17:09:24 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2021-02-05 17:09:24 +0000 |
commit | 80e7414fdb0be8da42097a82f14b8b723546796c (patch) | |
tree | 4478e981231e8e2cd3db56b1e4a716f76b7a1bae | |
parent | 3f9890ef73dced430d86801a1efc0e93ec50890e (diff) | |
parent | f1ee9c797b3cb37d90d3f9f7e53b1a5f06a8ab19 (diff) | |
download | gitlab-shell-13-13-stable.tar.gz |
Merge branch 'security-limit-fscanl-13-6' into '13-13-stable'v13.13.113-13-stable
Read limited input for yes answer
See merge request gitlab-org/security/gitlab-shell!2
-rw-r--r-- | CHANGELOG | 4 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | internal/command/twofactorrecover/twofactorrecover.go | 5 | ||||
-rw-r--r-- | internal/command/twofactorrecover/twofactorrecover_test.go | 8 |
4 files changed, 17 insertions, 2 deletions
@@ -1,3 +1,7 @@ +v13.13.1 + +- Read limited input when asking to generate new two-factor recovery codes + v13.13.0 - GitLab API Client support for client certificates !432 @@ -1 +1 @@ -13.13.0 +13.13.1 diff --git a/internal/command/twofactorrecover/twofactorrecover.go b/internal/command/twofactorrecover/twofactorrecover.go index f0a9e7b..f5a700a 100644 --- a/internal/command/twofactorrecover/twofactorrecover.go +++ b/internal/command/twofactorrecover/twofactorrecover.go @@ -3,6 +3,7 @@ package twofactorrecover import ( "context" "fmt" + "io" "strings" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" @@ -11,6 +12,8 @@ import ( "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/twofactorrecover" ) +const readerLimit = 1024 + type Command struct { Config *config.Config Args *commandargs.Shell @@ -34,7 +37,7 @@ func (c *Command) canContinue() bool { fmt.Fprintln(c.ReadWriter.Out, question) var answer string - fmt.Fscanln(c.ReadWriter.In, &answer) + fmt.Fscanln(io.LimitReader(c.ReadWriter.In, readerLimit), &answer) return answer == "yes" } diff --git a/internal/command/twofactorrecover/twofactorrecover_test.go b/internal/command/twofactorrecover/twofactorrecover_test.go index 92e3779..3272061 100644 --- a/internal/command/twofactorrecover/twofactorrecover_test.go +++ b/internal/command/twofactorrecover/twofactorrecover_test.go @@ -6,6 +6,7 @@ import ( "encoding/json" "io/ioutil" "net/http" + "strings" "testing" "github.com/stretchr/testify/require" @@ -114,6 +115,13 @@ func TestExecute(t *testing.T) { expectedOutput: question + "New recovery codes have *not* been generated. Existing codes will remain valid.\n", }, + { + desc: "With some other answer", + arguments: &commandargs.Shell{}, + answer: strings.Repeat("yes, but not really\n", 2048), + expectedOutput: question + + "New recovery codes have *not* been generated. Existing codes will remain valid.\n", + }, } for _, tc := range testCases { |