Skip to content

Commit 3814b5a

Browse files
GLVSKiritipoiana
authored andcommitted
Added event for default stable rule remove bulk data from disk
Signed-off-by: GLVS Kiriti <[email protected]>
1 parent ade98bb commit 3814b5a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
/*
3+
Copyright (C) 2024 The Falco Authors.
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
15+
package syscall
16+
17+
import (
18+
"os"
19+
"os/exec"
20+
"path/filepath"
21+
22+
"github.com/falcosecurity/event-generator/events"
23+
)
24+
25+
var _ = events.Register(RemoveBulkDataFromDisk)
26+
27+
func RemoveBulkDataFromDisk(h events.Helper) error {
28+
// Creates temporary data for testing, avoiding critical file deletion.
29+
tmpDir, err := os.MkdirTemp(os.TempDir(), "created-by-falco-event-generator")
30+
if err != nil {
31+
return err
32+
}
33+
34+
filename := filepath.Join(tmpDir, "file.txt")
35+
if err := os.WriteFile(filename, []byte("bulk data content"), os.FileMode(0755)); err != nil {
36+
return err
37+
}
38+
39+
// Generating the event
40+
const command = "shred"
41+
h.Log().Infof("attempting to run %s command to remove bulk data from disk", command)
42+
cmd := exec.Command("shred", "-u", tmpDir)
43+
err = cmd.Run()
44+
return err
45+
}

0 commit comments

Comments
 (0)