From 1d24c444c153968a33a6aa747950629ff7760c0c Mon Sep 17 00:00:00 2001 From: Robert May Date: Mon, 28 Jun 2021 16:18:00 +0100 Subject: Modify regex to prevent partial matches --- internal/command/commandargs/command_args_test.go | 9 +++++++-- internal/command/commandargs/shell.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/command/commandargs/command_args_test.go b/internal/command/commandargs/command_args_test.go index 0329c82..7b9f0ad 100644 --- a/internal/command/commandargs/command_args_test.go +++ b/internal/command/commandargs/command_args_test.go @@ -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 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}, diff --git a/internal/command/commandargs/shell.go b/internal/command/commandargs/shell.go index 9cf6720..589f58d 100644 --- a/internal/command/commandargs/shell.go +++ b/internal/command/commandargs/shell.go @@ -20,8 +20,8 @@ const ( ) var ( - whoKeyRegex = regexp.MustCompile(`\bkey-(?P\d+)\b`) - whoUsernameRegex = regexp.MustCompile(`\busername-(?P\S+)\b`) + whoKeyRegex = regexp.MustCompile(`\Akey-(?P\d+)\z`) + whoUsernameRegex = regexp.MustCompile(`\Ausername-(?P\S+)\z`) ) type Shell struct { -- cgit v1.2.1 From f2c8eecc2c4b195e9ba0bc129f5cbd5c53a04c89 Mon Sep 17 00:00:00 2001 From: Patrick Bajao Date: Fri, 23 Jul 2021 05:08:31 +0000 Subject: Update CHANGELOG and VERSION --- CHANGELOG | 4 ++++ VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3bb0f1f..5531d8a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +v13.19.1 + +- Modify regex to prevent partial matches + v13.19.0 - Don't finish the opentracing span early !466 diff --git a/VERSION b/VERSION index dc18eab..bf4ba65 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -13.19.0 +13.19.1 -- cgit v1.2.1