Align bundle path validation coverage
This commit is contained in:
@@ -70,11 +70,19 @@ func TestParseManifestRejectsInvalidDigestFormat(t *testing.T) {
|
||||
|
||||
func TestParseManifestRejectsUnsafeFilePaths(t *testing.T) {
|
||||
tests := []string{
|
||||
`"path": ""`,
|
||||
`"path": "."`,
|
||||
`"path": "./report.md"`,
|
||||
`"path": "../report.md"`,
|
||||
`"path": "/report.md"`,
|
||||
`"path": "nested/../report.md"`,
|
||||
`"path": "nested/./report.md"`,
|
||||
`"path": "nested//report.md"`,
|
||||
`"path": "nested\\report.md"`,
|
||||
`"path": "manifest.json"`,
|
||||
`"path": "nested/manifest.json"`,
|
||||
`"path": "` + storage.StateFileName + `"`,
|
||||
`"path": "nested/` + storage.StateFileName + `"`,
|
||||
}
|
||||
for _, replacement := range tests {
|
||||
t.Run(replacement, func(t *testing.T) {
|
||||
@@ -128,6 +136,16 @@ func TestValidateManifestRejectsInvalidManifest(t *testing.T) {
|
||||
manifest.Digest = BundleDigest(manifest.Files)
|
||||
return manifest
|
||||
},
|
||||
"nested manifest path": func(manifest Manifest) Manifest {
|
||||
manifest.Files[0].Path = "nested/manifest.json"
|
||||
manifest.Digest = BundleDigest(manifest.Files)
|
||||
return manifest
|
||||
},
|
||||
"nested state path": func(manifest Manifest) Manifest {
|
||||
manifest.Files[0].Path = "nested/" + storage.StateFileName
|
||||
manifest.Digest = BundleDigest(manifest.Files)
|
||||
return manifest
|
||||
},
|
||||
"duplicate path": func(manifest Manifest) Manifest {
|
||||
manifest.Files[1].Path = manifest.Files[0].Path
|
||||
manifest.Digest = BundleDigest(manifest.Files)
|
||||
|
||||
Reference in New Issue
Block a user