Skip to content

Commit

Permalink
adding bulk-size
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzack9999 committed Oct 12, 2020
1 parent 34656d1 commit a1cc52c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions v2/internal/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Options struct {
TemplatesDirectory string // TemplatesDirectory is the directory to use for storing templates
RateLimit int // Rate-Limit of requests per specified target
StopAtFirstMatch bool // Stop processing template at first full match (this may break chained requests)
BulkSize int // Number of targets analyzed in parallel for each template
}

type multiStringFlag []string
Expand Down Expand Up @@ -81,6 +82,7 @@ func ParseOptions() *Options {
flag.BoolVar(&options.TemplateList, "tl", false, "List available templates")
flag.IntVar(&options.RateLimit, "rate-limit", -1, "Per Target Rate-Limit")
flag.BoolVar(&options.StopAtFirstMatch, "stop-at-first-match", false, "Stop processing http requests at first match (this may break template/workflow logic)")
flag.IntVar(&options.BulkSize, "bulk-size", 150, "Number of hosts analyzed in parallel per template")

flag.Parse()

Expand Down
10 changes: 5 additions & 5 deletions v2/internal/runner/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"path"
"path/filepath"
"strings"
"sync"

tengo "github.com/d5/tengo/v2"
"github.com/d5/tengo/v2/stdlib"
Expand All @@ -21,6 +20,7 @@ import (
"github.com/projectdiscovery/nuclei/v2/pkg/requests"
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
"github.com/projectdiscovery/nuclei/v2/pkg/workflows"
"github.com/remeh/sizedwaitgroup"
)

// workflowTemplates contains the initialized workflow templates per template group
Expand Down Expand Up @@ -79,12 +79,12 @@ func (r *Runner) processTemplateWithList(p progress.IProgress, template *templat

var globalresult atomicboolean.AtomBool

var wg sync.WaitGroup
wg := sizedwaitgroup.New(r.options.BulkSize)

scanner := bufio.NewScanner(strings.NewReader(r.input))
for scanner.Scan() {
URL := scanner.Text()
wg.Add(1)
wg.Add()
go func(URL string) {
defer wg.Done()

Expand Down Expand Up @@ -125,12 +125,12 @@ func (r *Runner) processWorkflowWithList(p progress.IProgress, workflow *workflo

logicBytes := []byte(workflow.Logic)

var wg sync.WaitGroup
wg := sizedwaitgroup.New(r.options.BulkSize)

scanner := bufio.NewScanner(strings.NewReader(r.input))
for scanner.Scan() {
targetURL := scanner.Text()
wg.Add(1)
wg.Add()

go func(targetURL string) {
defer wg.Done()
Expand Down

0 comments on commit a1cc52c

Please sign in to comment.