From f033f7afd4d983a3c51f7ea996a148cd87fcf521 Mon Sep 17 00:00:00 2001 From: GLVS Kiriti Date: Tue, 26 Mar 2024 12:26:24 +0530 Subject: [PATCH] Added event for default rule create hidden file or directory Signed-off-by: GLVS Kiriti --- .../create_hidden_file_or_directory.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 events/syscall/create_hidden_file_or_directory.go diff --git a/events/syscall/create_hidden_file_or_directory.go b/events/syscall/create_hidden_file_or_directory.go new file mode 100644 index 00000000..a4f51ba2 --- /dev/null +++ b/events/syscall/create_hidden_file_or_directory.go @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2024 The Falco Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package syscall + +import ( + "os" + + "github.com/falcosecurity/event-generator/events" +) + +var _ = events.Register( + CreateHiddenFileOrDirectory, + events.WithDisabled(), // this rule is not included in falco_rules.yaml (stable rules), so disable the action +) + +func CreateHiddenFileOrDirectory(h events.Helper) error { + // Create a hidden directory + const directoryname = "/.created-by-event-generator" + h.Log().Infof("Created a hidden directory %s", directoryname) + defer os.Remove(directoryname) // Remove after function return + return os.Mkdir(directoryname, 0755) +}