-
Notifications
You must be signed in to change notification settings - Fork 0
/
hiddenfs_fuzz_test.go
46 lines (32 loc) · 1.02 KB
/
hiddenfs_fuzz_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//go:build go1.18
// +build go1.18
package backupfs
import (
"testing"
)
func FuzzHiddenFS_Create(f *testing.F) {
for _, seed := range []string{".", "/", "..", "\\", "hidefs_test.txt", "/var/opt/backups", "/var/opt"} {
f.Add(seed)
}
f.Fuzz(func(t *testing.T, filePath string) {
_, hiddenDir, _, base, fs := SetupTempDirHiddenFSTest(t)
// should not be able to create a file in that directory
fs.Create(filePath)
fs.MkdirAll(filePath, 0755)
fs.RemoveAll(filePath)
// anything in the hidden directory must stay as is
countFiles(t, base, hiddenDir, 2)
})
}
func FuzzHiddenFSRemoveAll(f *testing.F) {
for _, seed := range []string{".", "/", "..", "\\", "hidefs_test.txt", "/var/opt/backups", "/var/opt"} {
f.Add(seed)
}
f.Fuzz(func(t *testing.T, filePath string) {
_, hiddenDir, _, base, fs := SetupTempDirHiddenFSTest(t)
// should not be able to create a file in that directory
fs.RemoveAll(filePath)
// anything in the hidden directory must stay as is
countFiles(t, base, hiddenDir, 2)
})
}