Skip to content

Commit ceef898

Browse files
GLVSKiritipoiana
authored andcommitted
Using temporary data by creating them and removing them after completion
Signed-off-by: GLVS Kiriti <[email protected]>
1 parent 141a455 commit ceef898

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

events/syscall/read_ssh_information.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,20 @@ var _ = events.Register(
2929
)
3030

3131
func ReadSshInformation(h events.Helper) error {
32-
const filename = "/root/.ssh/known_hosts"
32+
// Creates temporary data for testing.
33+
directoryname := "/home/created-by-falco-event-generator/.ssh"
34+
if err := os.MkdirAll(directoryname, 0755); err != nil {
35+
return err
36+
}
37+
38+
filename := directoryname + "/known_hosts"
39+
if err := os.WriteFile(filename, nil, os.FileMode(0755)); err != nil {
40+
return err
41+
}
42+
3343
h.Log().Info("attempting to simulate SSH information read")
3444
file, err := os.Open(filename)
3545
defer file.Close()
46+
defer os.RemoveAll("/home/created-by-falco-event-generator")
3647
return err
3748
}

0 commit comments

Comments
 (0)