From a26f8da80003503bdf0718c0b5eb9637059af029 Mon Sep 17 00:00:00 2001 From: Ivan Yashchyshyn Date: Mon, 2 Dec 2024 12:35:53 +0100 Subject: [PATCH] SNOW-1792038 review fixes --- services/localfile/README.md | 2 +- services/localfile/server/shred_test.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/services/localfile/README.md b/services/localfile/README.md index 4ecb298a..6dd3a14f 100644 --- a/services/localfile/README.md +++ b/services/localfile/README.md @@ -132,7 +132,7 @@ sanssh --target $TARGET file chmod --mode=644 /opt/hello ``` ### sanssh file shred -Shred file using `/usr/bin/shred` (`/opt/homebrew/bin/shred` on Mac OS) utility. +Shred a file using `/usr/bin/shred` (`/opt/homebrew/bin/shred` on Mac OS) utility. Notice: this function is reliant on the presence of `shred` utility on the target system. Note that this utility is only effective on Hard Drives, it will not provide same level of security on Solid State Drives. diff --git a/services/localfile/server/shred_test.go b/services/localfile/server/shred_test.go index fedbdc6d..78dd753c 100644 --- a/services/localfile/server/shred_test.go +++ b/services/localfile/server/shred_test.go @@ -39,19 +39,21 @@ func Test_Shred(t *testing.T) { t.Cleanup(func() { conn.Close() }) client := pb.NewLocalFileClient(conn) - data := "data" + data := "myData" fileName := createTempFile(data, t) _, err = client.Shred(ctx, &pb.ShredRequest{ Filename: fileName, Force: false, - Zero: false, + Zero: true, Remove: false, }) testutil.FatalOnErr("shred", err, t) - if getFileContent(t, fileName) == data { - t.Fatal("shred did not work") + for _, b := range getFileContent(t, fileName) { + if b != 0 { + t.Fatal("shred did not work") + } } } @@ -79,13 +81,12 @@ func createTempFile(data string, t *testing.T) string { return tempFile.Name() } -func getFileContent(t *testing.T, path string) string { +func getFileContent(t *testing.T, path string) []byte { bytes, err := os.ReadFile(path) if err != nil { t.Fatalf("can't read file %q: %v", path, err) } - - return string(bytes) + return bytes } func shredIsUnavailable() bool {