From 87bf3f7a65445aa43cff9cf4ebea2add0b9a2307 Mon Sep 17 00:00:00 2001 From: Sylvie Crowe <107814465+oneirocosm@users.noreply.github.com> Date: Thu, 7 Dec 2023 18:33:16 -0800 Subject: [PATCH] allow @ symbol in user for ssh connections (#129) * allow @ symbol in user for ssh connections Previously, the @ symbol was only used as a way to either: - separate the user from the host - separate "sudo" from the user This change expands this to allow the username part of sudo@username@host or username@host to contain any number of @ symbols in addition to the ones previously allowed. Host is not allowed to contain an @ symbol as per the usual definition. * clean up regex changes Moved the dash in the regex pattern to the end to make it explicitly clear that it isn't part of a range. Removed the hostNameRe regex as it is unused. --- wavesrv/pkg/cmdrunner/cmdrunner.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index ab6600732..436eed95b 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -103,8 +103,7 @@ var SetVarScopes = []SetVarScope{ {ScopeName: "remote", VarNames: []string{}}, } -var hostNameRe = regexp.MustCompile("^[a-z][a-z0-9.-]*$") -var userHostRe = regexp.MustCompile("^(sudo@)?([a-z][a-z0-9._-]*)@([a-z0-9][a-z0-9.-]*)(?::([0-9]+))?$") +var userHostRe = regexp.MustCompile("^(sudo@)?([a-z][a-z0-9._@-]*)@([a-z0-9][a-z0-9.-]*)(?::([0-9]+))?$") var remoteAliasRe = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9_-]*$") var genericNameRe = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9_ .()<>,/\"'\\[\\]{}=+$@!*-]*$") var rendererRe = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9_.:-]*$")