nuclei/v2/internal/runner/processor.go

51 lines
1.2 KiB
Go
Raw Normal View History

2020-08-29 13:26:11 +00:00
package runner
import (
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
"github.com/remeh/sizedwaitgroup"
"go.uber.org/atomic"
2020-08-29 13:26:11 +00:00
)
// processTemplateWithList process a template on the URL list
func (r *Runner) processTemplateWithList(template *templates.Template) bool {
results := &atomic.Bool{}
2020-10-12 18:15:21 +00:00
wg := sizedwaitgroup.New(r.options.BulkSize)
r.hostMap.Scan(func(k, _ []byte) error {
URL := string(k)
2020-10-12 18:15:21 +00:00
wg.Add()
2020-08-29 13:26:11 +00:00
go func(URL string) {
defer wg.Done()
2020-12-29 13:18:13 +00:00
match, err := template.Executer.Execute(URL)
if err != nil {
gologger.Warning().Msgf("[%s] Could not execute step: %s\n", r.colorizer.BrightBlue(template.ID), err)
2020-08-29 13:26:11 +00:00
}
2020-12-29 15:02:04 +00:00
results.CAS(false, match)
2020-10-09 21:11:07 +00:00
}(URL)
return nil
})
2020-08-29 13:26:11 +00:00
wg.Wait()
return results.Load()
2020-08-29 13:26:11 +00:00
}
// processTemplateWithList process a template on the URL list
func (r *Runner) processWorkflowWithList(template *templates.Template) bool {
results := &atomic.Bool{}
2020-10-12 18:15:21 +00:00
wg := sizedwaitgroup.New(r.options.BulkSize)
2020-08-29 13:26:11 +00:00
r.hostMap.Scan(func(k, _ []byte) error {
URL := string(k)
wg.Add()
go func(URL string) {
2020-08-29 13:26:11 +00:00
defer wg.Done()
2021-02-22 12:19:02 +00:00
match := template.CompiledWorkflow.RunWorkflow(URL)
2020-12-29 15:02:04 +00:00
results.CAS(false, match)
}(URL)
return nil
})
2020-08-29 13:26:11 +00:00
wg.Wait()
return results.Load()
2020-08-29 13:26:11 +00:00
}