diff --git a/provider/image.go b/provider/image.go index f0ca9355..1dabdeda 100644 --- a/provider/image.go +++ b/provider/image.go @@ -898,7 +898,7 @@ func processLogLine(jm jsonmessage.JSONMessage, info += "failed to parse aux message: " + err.Error() } if err := (&resp).Unmarshal(infoBytes); err != nil { - info += "failed to parse aux message: " + err.Error() + info += "failed to parse info bytes: " + err.Error() } for _, vertex := range resp.Vertexes { info += fmt.Sprintf("digest: %+v\n", vertex.Digest) diff --git a/provider/provider.go b/provider/provider.go index 71e52098..7ae3c43c 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -582,7 +582,7 @@ func (accumulator *contextHashAccumulator) hashPath( if err != nil { return fmt.Errorf("could not copy symlink path %s to hash: %w", filePath, err) } - } else { + } else if fileMode.IsRegular() { // For regular files, we can hash their content. // TODO: consider only hashing file metadata to improve performance f, err := os.Open(filePath) @@ -737,7 +737,7 @@ func setConfiguration(configVars map[string]string) map[string]string { } func marshalBuildOnPreview(inputs resource.PropertyMap) bool { - //set default if not set + // set default if not set if inputs["buildOnPreview"].IsNull() || inputs["buildOnPreview"].ContainsUnknowns() { return false } diff --git a/provider/provider_test.go b/provider/provider_test.go index 35ee78fc..abaf19e1 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -4,6 +4,7 @@ import ( "context" "os" "path/filepath" + "syscall" "testing" "github.com/docker/distribution/reference" @@ -238,6 +239,28 @@ func TestHashDeepSymlinks(t *testing.T) { assert.NoError(t, err) } +func TestIgnoreIrregularFiles(t *testing.T) { + dir := t.TempDir() + + // Create a Dockerfile + dockerfile := filepath.Join(dir, "Dockerfile") + err := os.WriteFile(dockerfile, []byte{}, 0o600) + require.NoError(t, err) + + // Create a pipe which should be ignored. (We will time out trying to read + // it if it's not.) + pipe := filepath.Join(dir, "pipe") + err = syscall.Mkfifo(pipe, 0o666) + require.NoError(t, err) + // Confirm it's irregular. + fi, err := os.Stat(pipe) + require.NoError(t, err) + assert.False(t, fi.Mode().IsRegular()) + + _, err = hashContext(dir, dockerfile) + assert.NoError(t, err) +} + func TestHashUnignoredDirs(t *testing.T) { step1Dir := "./testdata/unignores/basedir" baseResult, err := hashContext(step1Dir, filepath.Join(step1Dir, defaultDockerfile))