Skip to content

Commit

Permalink
SNOW-1792038 review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-iyashchyshyn committed Dec 2, 2024
1 parent 827eb51 commit a26f8da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion services/localfile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
15 changes: 8 additions & 7 deletions services/localfile/server/shred_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a26f8da

Please sign in to comment.