From ecbea7a29094c4c313f6f38bf613ef1405e800ec Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 13 May 2024 15:47:03 +0100 Subject: [PATCH] download: Actually validate empty pathnames From the path module doc: If the path is empty, Base returns ".". If the path consists entirely of slashes, Base returns "/". Actually validate that we provide a filename when one is required, rather than failing with an error that /scratch exists but is not a file. Signed-off-by: Daniel Stone --- actions/download_action.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/download_action.go b/actions/download_action.go index 6527ca22..ee7e5b35 100644 --- a/actions/download_action.go +++ b/actions/download_action.go @@ -76,7 +76,7 @@ func (d *DownloadAction) validateFilename(context *debos.DebosContext, url *url. } else { filename = path.Base(d.Filename) } - if len(filename) == 0 { + if len(filename) == 0 || filename == "." || filename == "/" { return "", fmt.Errorf("Incorrect filename is provided for '%s'", d.Url) } filename = path.Join(context.Scratchdir, filename)