mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 17:35:28 +00:00
feat: fix reporting close functionality + misc (#6066)
This commit is contained in:
parent
3a3f5e271c
commit
d56524933f
@ -2,11 +2,12 @@ package reporting
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/projectdiscovery/nuclei/v3/pkg/reporting/exporters/mongo"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
|
"github.com/projectdiscovery/nuclei/v3/pkg/reporting/exporters/mongo"
|
||||||
|
|
||||||
"github.com/projectdiscovery/gologger"
|
"github.com/projectdiscovery/gologger"
|
||||||
"github.com/projectdiscovery/nuclei/v3/pkg/catalog/config"
|
"github.com/projectdiscovery/nuclei/v3/pkg/catalog/config"
|
||||||
json_exporter "github.com/projectdiscovery/nuclei/v3/pkg/reporting/exporters/jsonexporter"
|
json_exporter "github.com/projectdiscovery/nuclei/v3/pkg/reporting/exporters/jsonexporter"
|
||||||
@ -329,7 +330,7 @@ func (c *ReportingClient) CreateIssue(event *output.ResultEvent) error {
|
|||||||
// CloseIssue closes an issue in the tracker
|
// CloseIssue closes an issue in the tracker
|
||||||
func (c *ReportingClient) CloseIssue(event *output.ResultEvent) error {
|
func (c *ReportingClient) CloseIssue(event *output.ResultEvent) error {
|
||||||
for _, tracker := range c.trackers {
|
for _, tracker := range c.trackers {
|
||||||
if tracker.ShouldFilter(event) {
|
if !tracker.ShouldFilter(event) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := tracker.CloseIssue(event); err != nil {
|
if err := tracker.CloseIssue(event); err != nil {
|
||||||
|
|||||||
@ -240,7 +240,7 @@ func getIssueResponseFromJira(issue *jira.Issue) (*filters.CreateIssueResponse,
|
|||||||
// CreateIssue creates an issue in the tracker or updates the existing one
|
// CreateIssue creates an issue in the tracker or updates the existing one
|
||||||
func (i *Integration) CreateIssue(event *output.ResultEvent) (*filters.CreateIssueResponse, error) {
|
func (i *Integration) CreateIssue(event *output.ResultEvent) (*filters.CreateIssueResponse, error) {
|
||||||
if i.options.UpdateExisting {
|
if i.options.UpdateExisting {
|
||||||
issue, err := i.FindExistingIssue(event)
|
issue, err := i.FindExistingIssue(event, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not find existing issue")
|
return nil, errors.Wrap(err, "could not find existing issue")
|
||||||
} else if issue.ID != "" {
|
} else if issue.ID != "" {
|
||||||
@ -265,7 +265,7 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
issue, err := i.FindExistingIssue(event)
|
issue, err := i.FindExistingIssue(event, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if issue.ID != "" {
|
} else if issue.ID != "" {
|
||||||
@ -300,13 +300,16 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FindExistingIssue checks if the issue already exists and returns its ID
|
// FindExistingIssue checks if the issue already exists and returns its ID
|
||||||
func (i *Integration) FindExistingIssue(event *output.ResultEvent) (jira.Issue, error) {
|
func (i *Integration) FindExistingIssue(event *output.ResultEvent, useStatus bool) (jira.Issue, error) {
|
||||||
template := format.GetMatchedTemplateName(event)
|
template := format.GetMatchedTemplateName(event)
|
||||||
project := i.options.ProjectName
|
project := i.options.ProjectName
|
||||||
if i.options.ProjectID != "" {
|
if i.options.ProjectID != "" {
|
||||||
project = i.options.ProjectID
|
project = i.options.ProjectID
|
||||||
}
|
}
|
||||||
jql := fmt.Sprintf("summary ~ \"%s\" AND summary ~ \"%s\" AND status != \"%s\" AND project = \"%s\"", template, event.Host, i.options.StatusNot, project)
|
jql := fmt.Sprintf("summary ~ \"%s\" AND summary ~ \"%s\" AND project = \"%s\"", template, event.Host, project)
|
||||||
|
if useStatus {
|
||||||
|
jql = fmt.Sprintf("%s AND status != \"%s\"", jql, i.options.StatusNot)
|
||||||
|
}
|
||||||
|
|
||||||
searchOptions := &jira.SearchOptions{
|
searchOptions := &jira.SearchOptions{
|
||||||
MaxResults: 1, // if any issue exists, then we won't create a new one
|
MaxResults: 1, // if any issue exists, then we won't create a new one
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user