From 3e49a044d22635157916651f0acb5a062397b34b Mon Sep 17 00:00:00 2001 From: We-unite <3205135446@qq.com> Date: Fri, 9 Aug 2024 13:56:37 +0800 Subject: Add db structure, fix filePath, start filtering This commit I made several changes: - Use structure instead of simple bson.M(interface{}). bson.M has some shortcomings: 1) It makes the database in chaos and hard to read, but this's not important; 2) Some entrys may has more or less content than others, which makes it hard to decode and filt. So I design new data structure to encode and decode. Hopes that there's no bugs. - Fix the way to calculate file path. The original method is to add all the PATH entries together, that's totally wrong! PATH entry has several types, as it shows in "objtype". I can't find it in the kernel src code, so what i know is just "PARENT" means the dir the file is in, while the filename itself has the path, so we whould ignore all "PARENT"s. When the src code is found, we should check it again. - Fix bugs in updating. The update function of mongodb is set to required to has a '$' such as 'set'/'push', so when we update a whole doc, we should use replace but not update function. And, we should never ignore the error infomation it gives us. Hope that there's no more bugs for this Big Change. Now its' time to write filter as well as viewer. Best wishes with NO BUGS! --- src/global.go | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 src/global.go (limited to 'src/global.go') diff --git a/src/global.go b/src/global.go deleted file mode 100644 index 349ba6c..0000000 --- a/src/global.go +++ /dev/null @@ -1,49 +0,0 @@ -package main - -import ( - "sync" - "time" -) - -type eventType int - -const ( - NEWPID eventType = iota - PIDEXIT - EXECVE - FILEOPEN - FILECLOSE - FILEWRITE - PIVOTROOT - TYPENUM -) - -func (et eventType) String() string { - names := []string{"NEWPID", "PIDEXIT", "EXECVE", "FILEOPEN", "FILECLOSE", "FILEWRITE", "PIVOTROOT", "TYPENUM"} - if et < NEWPID || et > TYPENUM { - return "Unknown" - } - return names[et] -} - -type Event struct { - tag eventType - timestamp time.Time - pid, tgid int - ppid, parentTgid int - syscall int - syscallParam [4]uint64 - argc int - argv []string - cwd string - exit_code uint64 - exit_signal int - srcPath string - destPath string -} - -var wg sync.WaitGroup // 掌管协程 -var rawChan chan interface{} // 从接收到整理的管道 -var cookedChan chan Event // 整理好的信息的管道 -var syscallTable [500]string //记录一下系统调用 -var containerdPid int -- cgit v1.2.3-70-g09d2