forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotebook.go
48 lines (38 loc) · 1.05 KB
/
notebook.go
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
package main
import (
"bytes"
"context"
"fmt"
kingpin "gopkg.in/alecthomas/kingpin.v2"
"www.velocidex.com/golang/velociraptor/reporting"
)
var (
notebook_command = app.Command(
"notebook", "Export notebook as HTML.")
notebook_command_notebook_id = notebook_command.Arg(
"id", "Notebook ID to export").Required().String()
)
func doExportNotebook() {
config_obj, err := DefaultConfigLoader.WithRequiredFrontend().LoadAndValidate()
kingpin.FatalIfError(err, "Unable to load config file")
sm, err := startEssentialServices(config_obj)
kingpin.FatalIfError(err, "Starting services.")
defer sm.Close()
ctx := context.Background()
writer := &bytes.Buffer{}
err = reporting.ExportNotebookToHTML(
ctx, config_obj, *notebook_command_notebook_id, writer)
kingpin.FatalIfError(err, "Generating report")
fmt.Println(writer.String())
}
func init() {
command_handlers = append(command_handlers, func(command string) bool {
switch command {
case notebook_command.FullCommand():
doExportNotebook()
default:
return false
}
return true
})
}