From 3bb1004b1f5b0ceeeb1efa1caff915c6a1c02610 Mon Sep 17 00:00:00 2001 From: Jia Chao Date: Tue, 26 Nov 2024 17:43:48 +0800 Subject: [PATCH] fmt go files Signed-off-by: Jia Chao --- pkg/audit/fileaccess/audit.go | 4 ++-- pkg/audit/fileaccess/manager.go | 8 ++++---- pkg/audit/mount/audit.go | 5 +++-- pkg/audit/network/audit.go | 2 +- pkg/audit/process/audit.go | 10 +++++----- pkg/log/logger.go | 4 ++-- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pkg/audit/fileaccess/audit.go b/pkg/audit/fileaccess/audit.go index a6721fe..a597067 100644 --- a/pkg/audit/fileaccess/audit.go +++ b/pkg/audit/fileaccess/audit.go @@ -24,7 +24,7 @@ const ( BPF_PROGRAM_NAME = "restricted_file_open" ALLOWED_FILES_MAP_NAME = "allowed_access_files" DENIED_FILES_MAP_NAME = "denied_access_files" - MODULE = "access" + MODULE = "access" NEW_UTS_LEN = 64 PATH_MAX = 255 @@ -32,7 +32,7 @@ const ( ) type auditLog struct { - CGroupID uint64 + CGroupID uint64 PID uint32 UID uint32 Ret int32 diff --git a/pkg/audit/fileaccess/manager.go b/pkg/audit/fileaccess/manager.go index 80d0996..72d9375 100644 --- a/pkg/audit/fileaccess/manager.go +++ b/pkg/audit/fileaccess/manager.go @@ -48,10 +48,10 @@ func (m *Manager) Close() { func (m *Manager) Attach() error { for _, prog_name := range []string{"restricted_file_open", - "restricted_path_unlink", - "restricted_path_rmdir", - "restricted_path_rename", - "restricted_file_receive"} { //, "restricted_mmap_file", "restricted_file_ioctl"} { + "restricted_path_unlink", + "restricted_path_rmdir", + "restricted_path_rename", + "restricted_file_receive"} { //, "restricted_mmap_file", "restricted_file_ioctl"} { prog, err := m.mod.GetProgram(prog_name) if err != nil { return err diff --git a/pkg/audit/mount/audit.go b/pkg/audit/mount/audit.go index 2bf794d..47679a8 100644 --- a/pkg/audit/mount/audit.go +++ b/pkg/audit/mount/audit.go @@ -20,13 +20,14 @@ import ( ) const ( - BPF_OBJECT_NAME = "restricted-mount" - MODULE = "mount" + BPF_OBJECT_NAME = "restricted-mount" + MODULE = "mount" NEW_UTS_LEN = 64 TASK_COMM_LEN = 16 PATH_MAX = 255 ) + var BPF_PROGRAM_NAME []string = []string{"restricted_mount", "restricted_move_mount"} type auditLog struct { diff --git a/pkg/audit/network/audit.go b/pkg/audit/network/audit.go index 2f637a4..39b1762 100644 --- a/pkg/audit/network/audit.go +++ b/pkg/audit/network/audit.go @@ -34,7 +34,7 @@ const ( ACTION_MONITOR_STRING = "MONITOR" ACTION_BLOCKED_STRING = "BLOCKED" ACTION_UNKNOWN_STRING = "UNKNOWN" - MODULE = "network" + MODULE = "network" BLOCKED_IPV4 int32 = 0 BLOCKED_IPV6 int32 = 1 diff --git a/pkg/audit/process/audit.go b/pkg/audit/process/audit.go index 619e589..9a68774 100644 --- a/pkg/audit/process/audit.go +++ b/pkg/audit/process/audit.go @@ -20,12 +20,12 @@ import ( ) const ( - BPF_OBJECT_NAME = "restricted-process" - BPF_PROGRAM_FORK = "restricted_process_fork" - BPF_PROGRAM_EXEC = "restricted_process_exec" + BPF_OBJECT_NAME = "restricted-process" + BPF_PROGRAM_FORK = "restricted_process_fork" + BPF_PROGRAM_EXEC = "restricted_process_exec" ALLOWED_FILES_MAP_NAME = "allowed_access_files" DENIED_FILES_MAP_NAME = "denied_access_files" - MODULE = "process" + MODULE = "process" NEW_UTS_LEN = 64 PATH_MAX = 255 @@ -115,7 +115,7 @@ func RunAudit(ctx context.Context, wg *sync.WaitGroup, conf *config.Config) erro func newAuditLog(event auditLog) log.RestrictedProcessLog { auditEvent := log.AuditEventLog{ - Module: MODULE, + Module: MODULE, //Action: retToaction(event.Ret), Hostname: helpers.NodenameToString(event.Nodename), PID: event.PID, diff --git a/pkg/log/logger.go b/pkg/log/logger.go index 5cb0937..34ab02a 100644 --- a/pkg/log/logger.go +++ b/pkg/log/logger.go @@ -162,7 +162,7 @@ func (l *RestrictedNetworkLog) Info() { func (l *RestrictedFileAccessLog) Info() { Logger.WithFields(logrus.Fields{ - "Module": l.Module, + "Module": l.Module, "Action": l.Action, "Hostname": l.Hostname, "PID": l.PID, @@ -195,7 +195,7 @@ func (l *RestrictedMountLog) Info() { func (l *RestrictedProcessLog) Info() { Logger.WithFields(logrus.Fields{ - "Module": l.Module, + "Module": l.Module, //"Action": l.Action, "Hostname": l.Hostname, "PID": l.PID, -- Gitee