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 d6b32537 authored by Patrick Bajao's avatar Patrick Bajao
Browse files

Merge branch 'security-300265-13-18' into '13-18-stable'

Modify regex to prevent partial matches

See merge request gitlab-org/security/gitlab-shell!8
parents 584643e0 be84773e
No related branches found
No related tags found
No related merge requests found
v13.18.1
- Modify regex to prevent partial matches
v13.18.0
- Fix thread-safety issues in gitlab-shell !463
Loading
Loading
13.18.0
13.18.1
Loading
Loading
@@ -23,13 +23,18 @@ func TestParseSuccess(t *testing.T) {
env: sshenv.Env{IsSSHConnection: true, RemoteAddr: "1"},
arguments: []string{},
expectedArgs: &Shell{Arguments: []string{}, SshArgs: []string{}, CommandType: Discover, Env: sshenv.Env{IsSSHConnection: true, RemoteAddr: "1"}},
},
{
}, {
desc: "It finds the key id in any passed arguments",
executable: &executable.Executable{Name: executable.GitlabShell},
env: sshenv.Env{IsSSHConnection: true, RemoteAddr: "1"},
arguments: []string{"hello", "key-123"},
expectedArgs: &Shell{Arguments: []string{"hello", "key-123"}, SshArgs: []string{}, CommandType: Discover, GitlabKeyId: "123", Env: sshenv.Env{IsSSHConnection: true, RemoteAddr: "1"}},
}, {
desc: "It finds the key id only if the argument is of <key-id> format",
executable: &executable.Executable{Name: executable.GitlabShell},
env: sshenv.Env{IsSSHConnection: true, RemoteAddr: "1"},
arguments: []string{"hello", "username-key-123"},
expectedArgs: &Shell{Arguments: []string{"hello", "username-key-123"}, SshArgs: []string{}, CommandType: Discover, GitlabUsername: "key-123", Env: sshenv.Env{IsSSHConnection: true, RemoteAddr: "1"}},
}, {
desc: "It finds the username in any passed arguments",
executable: &executable.Executable{Name: executable.GitlabShell},
Loading
Loading
Loading
Loading
@@ -20,8 +20,8 @@ const (
)
var (
whoKeyRegex = regexp.MustCompile(`\bkey-(?P<keyid>\d+)\b`)
whoUsernameRegex = regexp.MustCompile(`\busername-(?P<username>\S+)\b`)
whoKeyRegex = regexp.MustCompile(`\Akey-(?P<keyid>\d+)\z`)
whoUsernameRegex = regexp.MustCompile(`\Ausername-(?P<username>\S+)\z`)
)
type Shell struct {
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