-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (45 loc) · 1.23 KB
/
main.go
File metadata and controls
49 lines (45 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"mig.ninja/mig/modules"
"mig.ninja/mig/modules/audit"
)
func main() {
var (
// provide serveraddress as an address of a server which accepts POST requests
// audit.rules.json contains the rules as specified by libaudit-go which are to be set in the kernel (modify them as required)
paramargs = `{"class":"parameters", "parameters":{"rulefilepath": "audit.rules.json", "serveraddress": "http://127.0.0.1:4443"}}`
out string
pretty = true
)
infd := bufio.NewReader(bytes.NewBuffer([]byte(paramargs)))
// instantiate and call module
// run := modules.Available["audit"].NewRun()
moduler := audit.GetInstance()
run := moduler.NewRun()
out = run.Run(infd)
if pretty {
var modres modules.Result
err := json.Unmarshal([]byte(out), &modres)
if err != nil {
panic(err)
}
out = ""
if _, ok := run.(modules.HasResultsPrinter); ok {
outRes, err := run.(modules.HasResultsPrinter).PrintResults(modres, false)
if err != nil {
panic(err)
}
for _, resLine := range outRes {
out += fmt.Sprintf("%s\n", resLine)
}
} else {
out = fmt.Sprintf("[error] no printer available for module '%s'\n", "audit")
}
}
fmt.Println(out)
return
}