-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
report.go
43 lines (38 loc) · 971 Bytes
/
report.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
package main
import (
"encoding/csv"
"encoding/json"
"fmt"
"github.com/TwiN/go-color"
_ "github.com/mattn/go-sqlite3"
"os"
)
func generateReport(results []DetectionResult, reportType string) {
switch reportType {
case "json":
reportJSON(results)
case "csv":
reportCSV(results)
default:
if *debug {
fmt.Println(color.Ize(color.Red, "[Debug] Invalid report type specified. No report generated."))
}
}
}
func reportJSON(results []DetectionResult) {
data, err := json.Marshal(results)
if err != nil {
fmt.Println(color.Ize(color.Red, ("Error generating JSON report:" + err.Error())))
return
}
fmt.Println(string(data))
}
func reportCSV(results []DetectionResult) {
writer := csv.NewWriter(os.Stdout)
defer writer.Flush()
writer.Write([]string{"Host", "IsHoneypot", "HoneypotType"})
for _, result := range results {
record := []string{result.Host, fmt.Sprintf("%t", result.IsHoneypot), result.HoneypotType}
writer.Write(record)
}
}