From ed3b80b5d727a6c155e0750349d34139d29c11f0 Mon Sep 17 00:00:00 2001 From: forgedhallpass <13679401+forgedhallpass@users.noreply.github.com> Date: Tue, 5 Oct 2021 22:02:09 +0300 Subject: [PATCH] If debug is enabled, show matchers that are not named also #1084 --- v2/pkg/operators/operators.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/v2/pkg/operators/operators.go b/v2/pkg/operators/operators.go index 86f1611b9..e88e34814 100644 --- a/v2/pkg/operators/operators.go +++ b/v2/pkg/operators/operators.go @@ -1,6 +1,8 @@ package operators import ( + "strconv" + "github.com/pkg/errors" "github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors" @@ -136,14 +138,10 @@ func (operators *Operators) Execute(data map[string]interface{}, match MatchFunc } } - for _, matcher := range operators.Matchers { - // Check if the matcher matched + for matcherIndex, matcher := range operators.Matchers { if isMatch, matched := match(data, matcher); isMatch { - // If the matcher has matched, and it's an OR - // write the first output then move to next matcher. - if matcherCondition == matchers.ORCondition && matcher.Name != "" { - result.Matches[matcher.Name] = matched - } + matcherName := getMatcherName(matcher, matcherIndex) + result.Matches[matcherName] = matched matches = true } else if matcherCondition == matchers.ANDCondition { @@ -172,6 +170,14 @@ func (operators *Operators) Execute(data map[string]interface{}, match MatchFunc return nil, false } +func getMatcherName(matcher *matchers.Matcher, matcherIndex int) string { + if matcher.Name != "" { + return matcher.Name + } else { + return matcher.Type + "-" + strconv.Itoa(matcherIndex) + } +} + // ExecuteInternalExtractors executes internal dynamic extractors func (operators *Operators) ExecuteInternalExtractors(data map[string]interface{}, extract ExtractFunc) map[string]interface{} { dynamicValues := make(map[string]interface{})