github.com/projectdiscovery/nuclei/v2@v2.9.15/pkg/protocols/common/helpers/writer/writer.go (about) 1 package writer 2 3 import ( 4 "github.com/projectdiscovery/gologger" 5 "github.com/projectdiscovery/nuclei/v2/pkg/output" 6 "github.com/projectdiscovery/nuclei/v2/pkg/progress" 7 "github.com/projectdiscovery/nuclei/v2/pkg/reporting" 8 ) 9 10 // WriteResult is a helper for writing results to the output 11 func WriteResult(data *output.InternalWrappedEvent, output output.Writer, progress progress.Progress, issuesClient reporting.Client) bool { 12 // Handle the case where no result found for the template. 13 // In this case, we just show misc information about the failed 14 // match for the template. 15 if !data.HasOperatorResult() { 16 return false 17 } 18 var matched bool 19 for _, result := range data.Results { 20 if err := output.Write(result); err != nil { 21 gologger.Warning().Msgf("Could not write output event: %s\n", err) 22 } 23 if !matched { 24 matched = true 25 } 26 progress.IncrementMatched() 27 28 if issuesClient != nil { 29 if err := issuesClient.CreateIssue(result); err != nil { 30 gologger.Warning().Msgf("Could not create issue on tracker: %s", err) 31 } 32 } 33 } 34 return matched 35 }