mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 23:45:24 +00:00
Merge pull request #867 from projectdiscovery/fix-filter-exclude-issue
Fixed filter exclude issue
This commit is contained in:
commit
25be233e34
@ -29,10 +29,9 @@ func (t *TagFilter) Match(tag, author, severity string) (bool, error) {
|
|||||||
matchedAny := false
|
matchedAny := false
|
||||||
if len(t.allowedTags) > 0 {
|
if len(t.allowedTags) > 0 {
|
||||||
_, ok := t.allowedTags[tag]
|
_, ok := t.allowedTags[tag]
|
||||||
if !ok {
|
if ok {
|
||||||
return false, nil
|
matchedAny = true
|
||||||
}
|
}
|
||||||
matchedAny = true
|
|
||||||
}
|
}
|
||||||
_, ok := t.block[tag]
|
_, ok := t.block[tag]
|
||||||
if ok {
|
if ok {
|
||||||
@ -76,10 +75,9 @@ func (t *TagFilter) MatchWithAllowedTags(allowed []string, tag, author, severity
|
|||||||
}
|
}
|
||||||
if len(allowedMap) > 0 {
|
if len(allowedMap) > 0 {
|
||||||
_, ok := allowedMap[tag]
|
_, ok := allowedMap[tag]
|
||||||
if !ok {
|
if ok {
|
||||||
return false, nil
|
matchedAny = true
|
||||||
}
|
}
|
||||||
matchedAny = true
|
|
||||||
}
|
}
|
||||||
_, ok := t.block[tag]
|
_, ok := t.block[tag]
|
||||||
if ok && !matchedAny {
|
if ok && !matchedAny {
|
||||||
|
|||||||
@ -40,16 +40,6 @@ func TestTagBasedFilter(t *testing.T) {
|
|||||||
require.Nil(t, err, "could not get match")
|
require.Nil(t, err, "could not get match")
|
||||||
require.True(t, matched, "could not get correct match")
|
require.True(t, matched, "could not get correct match")
|
||||||
})
|
})
|
||||||
t.Run("match-includes", func(t *testing.T) {
|
|
||||||
config := &Config{
|
|
||||||
Tags: []string{"fuzz"},
|
|
||||||
ExcludeTags: []string{"fuzz"},
|
|
||||||
}
|
|
||||||
filter := New(config)
|
|
||||||
matched, err := filter.Match("fuzz", "pdteam", "low")
|
|
||||||
require.Nil(t, err, "could not get match")
|
|
||||||
require.True(t, matched, "could not get correct match")
|
|
||||||
})
|
|
||||||
t.Run("match-author", func(t *testing.T) {
|
t.Run("match-author", func(t *testing.T) {
|
||||||
config := &Config{
|
config := &Config{
|
||||||
Authors: []string{"pdteam"},
|
Authors: []string{"pdteam"},
|
||||||
@ -66,6 +56,15 @@ func TestTagBasedFilter(t *testing.T) {
|
|||||||
matched, _ := filter.Match("fuzz", "pdteam", "high")
|
matched, _ := filter.Match("fuzz", "pdteam", "high")
|
||||||
require.True(t, matched, "could not get correct match")
|
require.True(t, matched, "could not get correct match")
|
||||||
})
|
})
|
||||||
|
t.Run("match-exclude-with-tags", func(t *testing.T) {
|
||||||
|
config := &Config{
|
||||||
|
Tags: []string{"tag"},
|
||||||
|
ExcludeTags: []string{"another"},
|
||||||
|
}
|
||||||
|
filter := New(config)
|
||||||
|
matched, _ := filter.Match("another", "pdteam", "high")
|
||||||
|
require.False(t, matched, "could not get correct match")
|
||||||
|
})
|
||||||
t.Run("match-conditions", func(t *testing.T) {
|
t.Run("match-conditions", func(t *testing.T) {
|
||||||
config := &Config{
|
config := &Config{
|
||||||
Authors: []string{"pdteam"},
|
Authors: []string{"pdteam"},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user