Add severity label to Gitlab/JIRA reporter

This commit is contained in:
Scott Bamforth 2021-09-17 21:08:48 +01:00
parent 10cc08c758
commit a4be346e4d
No known key found for this signature in database
GPG Key ID: E3B0A2DA619FB055
2 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package gitlab
import (
"fmt"
"github.com/projectdiscovery/nuclei/v2/pkg/output"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/format"
"github.com/xanzy/go-gitlab"
@ -48,12 +50,14 @@ func New(options *Options) (*Integration, error) {
func (i *Integration) CreateIssue(event *output.ResultEvent) error {
summary := format.Summary(event)
description := format.MarkdownDescription(event)
severityLabel := fmt.Sprintf("Severity: %s", event.Info.SeverityHolder.Severity.String())
_, _, err := i.client.Issues.CreateIssue(i.options.ProjectName, &gitlab.CreateIssueOptions{
Title: &summary,
Description: &description,
Labels: gitlab.Labels{i.options.IssueLabel},
Labels: gitlab.Labels{i.options.IssueLabel, severityLabel},
AssigneeIDs: []int{i.userID},
})
return err
}

View File

@ -60,6 +60,7 @@ func New(options *Options) (*Integration, error) {
// CreateNewIssue creates a new issue in the tracker
func (i *Integration) CreateNewIssue(event *output.ResultEvent) error {
summary := format.Summary(event)
severityLabel := fmt.Sprintf("Severity:%s", event.Info.SeverityHolder.Severity.String())
fields := &jira.IssueFields{
Assignee: &jira.User{AccountID: i.options.AccountID},
@ -68,6 +69,7 @@ func (i *Integration) CreateNewIssue(event *output.ResultEvent) error {
Type: jira.IssueType{Name: i.options.IssueType},
Project: jira.Project{Key: i.options.ProjectName},
Summary: summary,
Labels: []string{severityLabel},
}
// On-prem version of Jira server does not use AccountID
if !i.options.Cloud {
@ -77,6 +79,7 @@ func (i *Integration) CreateNewIssue(event *output.ResultEvent) error {
Type: jira.IssueType{Name: i.options.IssueType},
Project: jira.Project{Key: i.options.ProjectName},
Summary: summary,
Labels: []string{severityLabel},
}
}