From 655570b26f8123e0335714a035b4c50146df6674 Mon Sep 17 00:00:00 2001 From: Shahriyar Jalayeri Date: Tue, 24 Sep 2024 15:44:40 +0300 Subject: [PATCH] evetestkit : sanity check in AppSCPCopy Do sanity check in AppSCPCopy to make sure that the source does exist and it is not a directory. Signed-off-by: Shahriyar Jalayeri --- pkg/evetestkit/utils.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/evetestkit/utils.go b/pkg/evetestkit/utils.go index d0f98acc2..824c362cb 100644 --- a/pkg/evetestkit/utils.go +++ b/pkg/evetestkit/utils.go @@ -291,6 +291,14 @@ func (node *EveNode) AppSSHExec(appName, command string) (string, error) { // AppSCPCopy copies a file from the local machine to the app VM running on the EVE node. func (node *EveNode) AppSCPCopy(appName, localFile, remoteFile string) error { + info, err := os.Stat(localFile) + if os.IsNotExist(err) { + return fmt.Errorf("file %s does not exist", localFile) + } + if info.IsDir() { + return fmt.Errorf("file %s is a directory", localFile) + } + appConfig := node.getAppConfig(appName) if appConfig == nil { return fmt.Errorf("app %s not found, make sure to deploy app/vm with WithSSH option", appName)