Skip to content

Commit 71628cc

Browse files
committed
Merge remote-tracking branch 'origin'
2 parents 7f51de3 + f8842b1 commit 71628cc

File tree

6 files changed

+47
-13
lines changed

6 files changed

+47
-13
lines changed

pkg/reporting/reporting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (c *ReportingClient) CreateIssue(event *output.ResultEvent) error {
273273

274274
for _, tracker := range c.trackers {
275275
// process tracker specific allow/deny list
276-
if tracker.ShouldFilter(event) {
276+
if !tracker.ShouldFilter(event) {
277277
continue
278278
}
279279

pkg/reporting/trackers/gitea/gitea.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
139139

140140
// ShouldFilter determines if an issue should be logged to this tracker
141141
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
142-
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
142+
if i.options.AllowList != nil && !i.options.AllowList.GetMatch(event) {
143143
return false
144144
}
145145

146146
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {
147-
return true
147+
return false
148148
}
149149

150-
return false
150+
return true
151151
}
152152

153153
func (i *Integration) findIssueByTitle(title string) (*gitea.Issue, error) {

pkg/reporting/trackers/github/github.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ func (i *Integration) Name() string {
175175

176176
// ShouldFilter determines if an issue should be logged to this tracker
177177
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
178-
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
178+
if i.options.AllowList != nil && !i.options.AllowList.GetMatch(event) {
179179
return false
180180
}
181181

182182
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {
183-
return true
183+
return false
184184
}
185185

186-
return false
186+
return true
187187
}
188188

189189
func (i *Integration) findIssueByTitle(ctx context.Context, title string) (*github.Issue, error) {

pkg/reporting/trackers/gitlab/gitlab.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
164164

165165
// ShouldFilter determines if an issue should be logged to this tracker
166166
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
167-
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
167+
if i.options.AllowList != nil && !i.options.AllowList.GetMatch(event) {
168168
return false
169169
}
170170

171171
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {
172-
return true
172+
return false
173173
}
174174

175-
return false
175+
return true
176176
}

pkg/reporting/trackers/jira/jira.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,13 @@ func (i *Integration) FindExistingIssue(event *output.ResultEvent) (jira.Issue,
315315

316316
// ShouldFilter determines if an issue should be logged to this tracker
317317
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
318-
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
318+
if i.options.AllowList != nil && !i.options.AllowList.GetMatch(event) {
319319
return false
320320
}
321321

322322
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {
323-
return true
323+
return false
324324
}
325325

326-
return false
326+
return true
327327
}

pkg/reporting/trackers/jira/jira_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import (
44
"strings"
55
"testing"
66

7+
"github.com/projectdiscovery/nuclei/v3/pkg/model"
8+
"github.com/projectdiscovery/nuclei/v3/pkg/model/types/severity"
9+
"github.com/projectdiscovery/nuclei/v3/pkg/output"
10+
"github.com/projectdiscovery/nuclei/v3/pkg/reporting/trackers/filters"
711
"github.com/stretchr/testify/require"
812
)
913

@@ -36,3 +40,33 @@ func TestTableCreation(t *testing.T) {
3640
`
3741
require.Equal(t, expected, table)
3842
}
43+
44+
func Test_ShouldFilter_Tracker(t *testing.T) {
45+
jiraIntegration := &Integration{
46+
options: &Options{AllowList: &filters.Filter{
47+
Severities: severity.Severities{severity.Critical},
48+
}},
49+
}
50+
51+
require.False(t, jiraIntegration.ShouldFilter(&output.ResultEvent{Info: model.Info{
52+
SeverityHolder: severity.Holder{Severity: severity.Info},
53+
}}))
54+
require.True(t, jiraIntegration.ShouldFilter(&output.ResultEvent{Info: model.Info{
55+
SeverityHolder: severity.Holder{Severity: severity.Critical},
56+
}}))
57+
58+
t.Run("deny-list", func(t *testing.T) {
59+
jiraIntegration := &Integration{
60+
options: &Options{DenyList: &filters.Filter{
61+
Severities: severity.Severities{severity.Critical},
62+
}},
63+
}
64+
65+
require.True(t, jiraIntegration.ShouldFilter(&output.ResultEvent{Info: model.Info{
66+
SeverityHolder: severity.Holder{Severity: severity.Info},
67+
}}))
68+
require.False(t, jiraIntegration.ShouldFilter(&output.ResultEvent{Info: model.Info{
69+
SeverityHolder: severity.Holder{Severity: severity.Critical},
70+
}}))
71+
})
72+
}

0 commit comments

Comments
 (0)