From 9ec042f2f62bc95154d6c8b3215a2e7853f8f5c6 Mon Sep 17 00:00:00 2001 From: orcas Date: Sun, 15 Sep 2019 00:32:54 +0800 Subject: Show undecryptable filenames if they match supplied glob Resolves https://github.com/rfjakob/gocryptfs/issues/393 --- tests/cli/cli_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests/cli') diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index 3e1bf42..232c8cc 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -8,6 +8,7 @@ import ( "os" "os/exec" "strconv" + "strings" "syscall" "testing" "time" @@ -644,3 +645,43 @@ func TestSymlinkedCipherdir(t *testing.T) { t.Errorf("wrong Readdirnames result: %v", names) } } + +func TestBypass(t *testing.T) { + dir := test_helpers.InitFS(t) + mnt := dir + ".mnt" + + test_helpers.MountOrFatal(t, dir, mnt, "-badname=*", "-extpass=echo test") + defer test_helpers.UnmountPanic(mnt) + + file := mnt + "/file" + err := ioutil.WriteFile(file, []byte("somecontent"), 0600) + if err != nil { + t.Fatal(err) + } + + invalid_file_name := "invalid_file" + invalid_file := dir + "/" + invalid_file_name + err = ioutil.WriteFile(invalid_file, []byte("somecontent"), 0600) + if err != nil { + t.Fatal(err) + } + + f, err := os.Open(mnt) + if err != nil { + t.Fatal(err) + } + defer f.Close() + + names, err := f.Readdirnames(0) + found := false + for _, name := range names { + if strings.Contains(name, invalid_file_name) { + found = true + break + } + } + + if !found { + t.Errorf("did not find invalid name %s in %v", invalid_file_name, names) + } +} -- cgit v1.2.3