As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit ce93aeae authored by Nick Thomas's avatar Nick Thomas
Browse files

Merge branch 'security-limit-fscanl-13-9' into '13-16-stable'

Read limited input for yes answer

See merge request gitlab-org/security/gitlab-shell!5
parents 69fc715f 205e0a87
No related branches found
No related tags found
No related merge requests found
v13.16.1
- Read limited input for yes answer
v13.16.0
- RFC: Simple built-in SSH server !394
Loading
Loading
13.16.0
13.16.1
Loading
Loading
@@ -3,6 +3,7 @@ package twofactorrecover
import (
"context"
"fmt"
"io"
"strings"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs"
Loading
Loading
@@ -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
Loading
Loading
@@ -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"
}
Loading
Loading
Loading
Loading
@@ -6,6 +6,7 @@ import (
"encoding/json"
"io/ioutil"
"net/http"
"strings"
"testing"
"github.com/stretchr/testify/require"
Loading
Loading
@@ -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", 1024),
expectedOutput: question +
"New recovery codes have *not* been generated. Existing codes will remain valid.\n",
},
}
for _, tc := range testCases {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment