From ca268132b9f6db7c1cce7d065d208c9fd686bb5d Mon Sep 17 00:00:00 2001 From: Casey Lee Date: Thu, 24 Jan 2019 22:17:58 -0800 Subject: [PATCH] fix 22: require prefix './' for local actions --- actions/action.go | 6 ++++-- actions/runner_test.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/actions/action.go b/actions/action.go index 79162e9..3913341 100644 --- a/actions/action.go +++ b/actions/action.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "regexp" + "strings" "github.com/nektos/act/common" log "github.com/sirupsen/logrus" @@ -14,9 +15,10 @@ import ( // imageURL is the directory where a `Dockerfile` should exist func parseImageLocal(workingDir string, contextDir string) (contextDirOut string, tag string, ok bool) { - if !filepath.IsAbs(contextDir) { - contextDir = filepath.Join(workingDir, contextDir) + if !strings.HasPrefix(contextDir, "./") { + return "", "", false } + contextDir = filepath.Join(workingDir, contextDir) if _, err := os.Stat(filepath.Join(contextDir, "Dockerfile")); os.IsNotExist(err) { log.Debugf("Ignoring missing Dockerfile '%s/Dockerfile'", contextDir) return "", "", false diff --git a/actions/runner_test.go b/actions/runner_test.go index 890eca1..bd1d31e 100644 --- a/actions/runner_test.go +++ b/actions/runner_test.go @@ -43,7 +43,8 @@ func TestParseImageLocal(t *testing.T) { }{ {"docker://myhost.com/foo/bar", "", "", false}, {"http://google.com:8080", "", "", false}, - {"example/action1", "/example/action1", "action1:", true}, + {"example/action1", "", "", false}, + {"./example/action1", "/example/action1", "action1:", true}, } revision, _, err := common.FindGitRevision(".")