Skip to content

Commit

Permalink
Reduced code size
Browse files Browse the repository at this point in the history
Signed-off-by: GLVS Kiriti <glvskiriti2003369@gmail.com>
  • Loading branch information
GLVSKiriti authored and poiana committed Apr 2, 2024
1 parent 0ecd93a commit 1ecb03f
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions events/syscall/adding_ssh_keys_to_authorized_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,18 @@ import (

var _ = events.Register(
AddingSshKeysToAuthorizedKeys,
events.WithDisabled(), // this rules is not included in falco_rules.yaml (stable rules), so disable the action
// events.WithDisabled(), // this rules is not included in falco_rules.yaml (stable rules), so disable the action
)

func AddingSshKeysToAuthorizedKeys(h events.Helper) error {
// Creates temporary data for testing.
directoryname := "/home/created-by-falco-event-generator/.ssh"
if err := os.MkdirAll(directoryname, 0755); err != nil {
return err
}

filename := directoryname + "/authorized_keys"
if err := os.WriteFile(filename, nil, os.FileMode(0755)); err != nil {

if err := os.MkdirAll(directoryname, 0755); err != nil {
return err
}

h.Log().Infof("writing to %s", filename)
err := os.WriteFile(filename, []byte("ssh-rsa <ssh_public_key>\n"), os.FileMode(0755))

defer os.RemoveAll("/home/created-by-falco-event-generator")
return err
return os.WriteFile(filename, []byte("ssh-rsa <ssh_public_key>\n"), os.FileMode(0755))
}

0 comments on commit 1ecb03f

Please sign in to comment.