Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/reporting/reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package reporting

import (
"fmt"
"github.com/projectdiscovery/nuclei/v3/pkg/reporting/exporters/mongo"
"os"
"strings"
"sync/atomic"

"github.com/projectdiscovery/nuclei/v3/pkg/reporting/exporters/mongo"

"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/nuclei/v3/pkg/catalog/config"
json_exporter "github.com/projectdiscovery/nuclei/v3/pkg/reporting/exporters/jsonexporter"
Expand Down Expand Up @@ -329,7 +330,7 @@ func (c *ReportingClient) CreateIssue(event *output.ResultEvent) error {
// CloseIssue closes an issue in the tracker
func (c *ReportingClient) CloseIssue(event *output.ResultEvent) error {
for _, tracker := range c.trackers {
if tracker.ShouldFilter(event) {
if !tracker.ShouldFilter(event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the inverted condition in CloseIssue method.

The condition has been inverted which changes the intended behavior. Issues will now be closed when they should NOT be filtered, which appears to be incorrect.

Apply this diff to fix the logic:

-		if !tracker.ShouldFilter(event) {
+		if tracker.ShouldFilter(event) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if !tracker.ShouldFilter(event) {
if tracker.ShouldFilter(event) {

continue
}
if err := tracker.CloseIssue(event); err != nil {
Expand Down
11 changes: 7 additions & 4 deletions pkg/reporting/trackers/jira/jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func getIssueResponseFromJira(issue *jira.Issue) (*filters.CreateIssueResponse,
// CreateIssue creates an issue in the tracker or updates the existing one
func (i *Integration) CreateIssue(event *output.ResultEvent) (*filters.CreateIssueResponse, error) {
if i.options.UpdateExisting {
issue, err := i.FindExistingIssue(event)
issue, err := i.FindExistingIssue(event, true)
if err != nil {
return nil, errors.Wrap(err, "could not find existing issue")
} else if issue.ID != "" {
Expand All @@ -265,7 +265,7 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
return nil
}

issue, err := i.FindExistingIssue(event)
issue, err := i.FindExistingIssue(event, false)
if err != nil {
return err
} else if issue.ID != "" {
Expand Down Expand Up @@ -300,13 +300,16 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
}

// 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)
project := i.options.ProjectName
if 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{
MaxResults: 1, // if any issue exists, then we won't create a new one
Expand Down
Loading