Skip to content

Commit 12c60b7

Browse files
authored
fix: E2E test data identified as malicious file by antivirus software (#1255)
Fix: - encode the original `zip_bomb.zip` file as `zip_bomb.zip.base64`, and decode the file on the fly to avoid it being identified as a malicious file. --------- Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
1 parent 2af2853 commit 12c60b7

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

test/e2e/suite/plugin/install.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
package plugin
1515

1616
import (
17+
"encoding/base64"
18+
"fmt"
19+
"os"
1720
"path/filepath"
1821

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

7982
It("with zip bomb total file size exceeds 256 MiB size limit", func() {
8083
Host(nil, func(notation *utils.ExecOpts, _ *Artifact, vhost *utils.VirtualHost) {
81-
notation.ExpectFailure().Exec("plugin", "install", "--file", filepath.Join(NotationE2EMaliciousPluginArchivePath, "zip_bomb.zip"), "-v").
84+
encodedFilePath := filepath.Join(NotationE2EMaliciousPluginArchivePath, "zip_bomb.zip.base64")
85+
encoded, err := os.ReadFile(encodedFilePath)
86+
if err != nil {
87+
Fail(fmt.Sprintf("failed to read file %s: %v", encodedFilePath, err))
88+
}
89+
// decode base64
90+
decoded, err := base64.StdEncoding.DecodeString(string(encoded))
91+
if err != nil {
92+
Fail(fmt.Sprintf("failed to decode file %s: %v", encodedFilePath, err))
93+
}
94+
targetPath := vhost.AbsolutePath(NotationDirName, "zip_bomb.zip")
95+
err = os.WriteFile(targetPath, decoded, 0644)
96+
if err != nil {
97+
Fail(fmt.Sprintf("failed to write file %s: %v", targetPath, err))
98+
}
99+
100+
notation.ExpectFailure().Exec("plugin", "install", "--file", targetPath, "-v").
82101
MatchErrContent("Error: plugin installation failed: total file size reached the 256 MiB size limit\n")
83102
})
84103
})
-41.4 KB
Binary file not shown.

test/e2e/testdata/malicious-plugin/zip_bomb.zip.base64

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)