-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoutsuitJiraIntegration.go
71 lines (58 loc) · 1.92 KB
/
scoutsuitJiraIntegration.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"github.com/andygrunwald/go-jira"
)
/*
This example uses the go-jira library to interact with Jira API. The main function reads in the JSON file, unmarshals it into a Report struct, and then iterates through the findings. For each finding, it creates a new Jira issue with the details of the finding, such as service, region, resource, issue, recommendation, and severity.
Make sure you have to replace the url, username and password with your jira instance details and adjust the project key, issue type, and priority 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)
// Jira integration
jiraClient, err := jira.NewClient(nil, "https://your-jira-instance.com")
if err != nil {
fmt.Println(err)
}
jiraClient.Authentication.SetBasicAuth("username", "password")
for _, finding := range report.Findings {
issue := jira.Issue{
Fields: &jira.IssueFields{
Project: jira.Project{
Key: "SEC",
},
Summary: fmt.Sprintf("%s - %s - %s", finding.Service, finding.Region, finding.Issue),
Description: fmt.Sprintf("Resource: %s\nRecommendation: %s\nSeverity: %s", finding.Resource, finding.Recommendation, finding.Severity),
Type: jira.IssueType{
Name: "Task",
},
Priority: jira.Priority{
Name: "High",
},
},
}
_, _, err := jiraClient.Issue.Create(&issue)
if err != nil {
fmt.Println(err)
}
fmt.Println("Successfully created issue for finding: ", finding.Issue)
}
}