Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/protocols/common/helpers/writer/writer.go
2073 views
1
package writer
2
3
import (
4
"github.com/projectdiscovery/gologger"
5
"github.com/projectdiscovery/nuclei/v3/pkg/output"
6
"github.com/projectdiscovery/nuclei/v3/pkg/progress"
7
"github.com/projectdiscovery/nuclei/v3/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 issuesClient != nil {
21
if err := issuesClient.CreateIssue(result); err != nil {
22
gologger.Warning().Msgf("Could not create issue on tracker: %s", err)
23
}
24
}
25
if err := output.Write(result); err != nil {
26
gologger.Warning().Msgf("Could not write output event: %s\n", err)
27
}
28
if !matched {
29
matched = true
30
}
31
progress.IncrementMatched()
32
}
33
return matched
34
}
35
36