diff options
author | We-unite <3205135446@qq.com> | 2024-08-09 13:56:37 +0800 |
---|---|---|
committer | We-unite <3205135446@qq.com> | 2024-08-12 14:16:51 +0800 |
commit | 3e49a044d22635157916651f0acb5a062397b34b (patch) | |
tree | 254cd9a2605fa003f4579e7c5510e6e2aea19375 /src/global.go | |
parent | ea32e017e579f168d87732893335c38d539ac2f1 (diff) | |
download | godo-3e49a044d22635157916651f0acb5a062397b34b.tar.gz godo-3e49a044d22635157916651f0acb5a062397b34b.zip |
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!
Diffstat (limited to 'src/global.go')
-rw-r--r-- | src/global.go | 49 |
1 files changed, 0 insertions, 49 deletions
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 @@ | |||
1 | package main | ||
2 | |||
3 | import ( | ||
4 | "sync" | ||
5 | "time" | ||
6 | ) | ||
7 | |||
8 | type eventType int | ||
9 | |||
10 | const ( | ||
11 | NEWPID eventType = iota | ||
12 | PIDEXIT | ||
13 | EXECVE | ||
14 | FILEOPEN | ||
15 | FILECLOSE | ||
16 | FILEWRITE | ||
17 | PIVOTROOT | ||
18 | TYPENUM | ||
19 | ) | ||
20 | |||
21 | func (et eventType) String() string { | ||
22 | names := []string{"NEWPID", "PIDEXIT", "EXECVE", "FILEOPEN", "FILECLOSE", "FILEWRITE", "PIVOTROOT", "TYPENUM"} | ||
23 | if et < NEWPID || et > TYPENUM { | ||
24 | return "Unknown" | ||
25 | } | ||
26 | return names[et] | ||
27 | } | ||
28 | |||
29 | type Event struct { | ||
30 | tag eventType | ||
31 | timestamp time.Time | ||
32 | pid, tgid int | ||
33 | ppid, parentTgid int | ||
34 | syscall int | ||
35 | syscallParam [4]uint64 | ||
36 | argc int | ||
37 | argv []string | ||
38 | cwd string | ||
39 | exit_code uint64 | ||
40 | exit_signal int | ||
41 | srcPath string | ||
42 | destPath string | ||
43 | } | ||
44 | |||
45 | var wg sync.WaitGroup // 掌管协程 | ||
46 | var rawChan chan interface{} // 从接收到整理的管道 | ||
47 | var cookedChan chan Event // 整理好的信息的管道 | ||
48 | var syscallTable [500]string //记录一下系统调用 | ||
49 | var containerdPid int | ||