Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion test/e2e/suite/plugin/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
package plugin

import (
"encoding/base64"
"fmt"
"os"
"path/filepath"

. "github.com/notaryproject/notation/test/e2e/internal/notation"
Expand Down Expand Up @@ -78,7 +81,23 @@ var _ = Describe("notation plugin install", func() {

It("with zip bomb total file size exceeds 256 MiB size limit", func() {
Host(nil, func(notation *utils.ExecOpts, _ *Artifact, vhost *utils.VirtualHost) {
notation.ExpectFailure().Exec("plugin", "install", "--file", filepath.Join(NotationE2EMaliciousPluginArchivePath, "zip_bomb.zip"), "-v").
encodedFilePath := filepath.Join(NotationE2EMaliciousPluginArchivePath, "zip_bomb.zip.base64")
encoded, err := os.ReadFile(encodedFilePath)
if err != nil {
Fail(fmt.Sprintf("failed to read file %s: %v", encodedFilePath, err))
}
// decode base64
decoded, err := base64.StdEncoding.DecodeString(string(encoded))
if err != nil {
Fail(fmt.Sprintf("failed to decode file %s: %v", encodedFilePath, err))
}
targetPath := vhost.AbsolutePath(NotationDirName, "zip_bomb.zip")
err = os.WriteFile(targetPath, decoded, 0644)
if err != nil {
Fail(fmt.Sprintf("failed to write file %s: %v", targetPath, err))
}

notation.ExpectFailure().Exec("plugin", "install", "--file", targetPath, "-v").
MatchErrContent("Error: plugin installation failed: total file size reached the 256 MiB size limit\n")
})
})
Expand Down
Binary file removed test/e2e/testdata/malicious-plugin/zip_bomb.zip
Binary file not shown.
1 change: 1 addition & 0 deletions test/e2e/testdata/malicious-plugin/zip_bomb.zip.base64

Large diffs are not rendered by default.

Loading