-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoutsuiteJsonParser.go
47 lines (38 loc) · 1.37 KB
/
scoutsuiteJsonParser.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
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
/*
This example defines a Report struct that has a slice of Finding structs, which each have fields for the service, region, resource, issue, recommendation, and severity. The main function reads in the JSON file, unmarshals it into a Report struct, and then iterates through the findings to print out the values of each field.
Please note that this code is just an example, it may not work as is, and you may need to adjust the struct fields and the json file name accordingly.
*/
type Report struct {
Findings []Finding `json:"findings"`
}
type Finding struct {
Service string `json:"service"`
Region string `json:"region"`
Resource string `json:"resource"`
Issue string `json:"issue"`
Recommendation string `json:"recommendation"`
Severity string `json:"severity"`
}
func main() {
jsonFile, err := ioutil.ReadFile("scoutsuite-report.json")
if err != nil {
fmt.Println(err)
}
var report Report
json.Unmarshal(jsonFile, &report)
for _, finding := range report.Findings {
fmt.Println("Service:", finding.Service)
fmt.Println("Region:", finding.Region)
fmt.Println("Resource:", finding.Resource)
fmt.Println("Issue:", finding.Issue)
fmt.Println("Recommendation:", finding.Recommendation)
fmt.Println("Severity:", finding.Severity)
fmt.Println("-------------------")
}
}