MCPcopy
hub / github.com/docker/compose / TestWriteComposeFileWithExtendsPathTraversal

Function TestWriteComposeFileWithExtendsPathTraversal

pkg/remote/oci_test.go:120–139  ·  pkg/remote/oci_test.go::TestWriteComposeFileWithExtendsPathTraversal
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestWriteComposeFileWithExtendsPathTraversal(t *testing.T) {
121 tmpDir := t.TempDir()
122
123 // Create a layer with com.docker.compose.extends=true and a path traversal attempt
124 layer := spec.Descriptor{
125 MediaType: "application/vnd.docker.compose.file.v1+yaml",
126 Digest: "sha256:test123",
127 Size: 100,
128 Annotations: map[string]string{
129 "com.docker.compose.extends": "true",
130 "com.docker.compose.file": "../other",
131 },
132 }
133
134 content := []byte("services:\n test:\n image: nginx\n")
135
136 // writeComposeFile should return an error due to path traversal
137 err := writeComposeFile(layer, 0, tmpDir, content)
138 assert.Error(t, err, "invalid OCI artifact")
139}

Callers

nothing calls this directly

Calls 3

writeComposeFileFunction · 0.85
TempDirMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected