From eecacc08bf7782ef4796eb980a113001be1c69d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:33:34 +0200 Subject: [PATCH] #42 Allow deletion of ./* --- internal/runner/nomad_runner.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/runner/nomad_runner.go b/internal/runner/nomad_runner.go index bb01090..45bbfa9 100644 --- a/internal/runner/nomad_runner.go +++ b/internal/runner/nomad_runner.go @@ -253,11 +253,15 @@ func fileDeletionCommand(pathsToDelete []dto.FilePath) string { } command := "rm --recursive --force " for _, filePath := range pathsToDelete { - // To avoid command injection, filenames need to be quoted. - // See https://unix.stackexchange.com/questions/347332/what-characters-need-to-be-escaped-in-files-without-quotes - // for details. - singleQuoteEscapedFileName := strings.ReplaceAll(filePath.Cleaned(), "'", "'\\''") - command += fmt.Sprintf("'%s' ", singleQuoteEscapedFileName) + if filePath == "./*" { + command += "./* " + } else { + // To avoid command injection, filenames need to be quoted. + // See https://unix.stackexchange.com/questions/347332/what-characters-need-to-be-escaped-in-files-without-quotes + // for details. + singleQuoteEscapedFileName := strings.ReplaceAll(filePath.Cleaned(), "'", "'\\''") + command += fmt.Sprintf("'%s' ", singleQuoteEscapedFileName) + } } command += ";" return command