Skip to content

Commit

Permalink
Added WithResponseReadSize function to allow SDK users to modify max …
Browse files Browse the repository at this point in the history
…response read opt (#5961)

* added WithResponseReadSize function to allow SDK users to modify max response read opt

* Update lib/config.go

improved comment, changed casing of param name, added negative input check

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fixing rabbitai commit >:(

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
meme-lord and coderabbitai[bot] authored Jan 14, 2025
1 parent 2450ecb commit 08c46ff
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,39 +126,44 @@ func WithConcurrency(opts Concurrency) NucleiSDKOptions {
// minimum required is 1
if opts.TemplateConcurrency <= 0 {
return errors.New("template threads must be at least 1")
} else {
e.opts.TemplateThreads = opts.TemplateConcurrency
}
if opts.HostConcurrency <= 0 {
return errors.New("host concurrency must be at least 1")
} else {
e.opts.BulkSize = opts.HostConcurrency
}
if opts.HeadlessHostConcurrency <= 0 {
return errors.New("headless host concurrency must be at least 1")
} else {
e.opts.HeadlessBulkSize = opts.HeadlessHostConcurrency
}
if opts.HeadlessTemplateConcurrency <= 0 {
return errors.New("headless template threads must be at least 1")
} else {
e.opts.HeadlessTemplateThreads = opts.HeadlessTemplateConcurrency
}
if opts.JavascriptTemplateConcurrency <= 0 {
return errors.New("js must be at least 1")
} else {
e.opts.JsConcurrency = opts.JavascriptTemplateConcurrency
}
if opts.TemplatePayloadConcurrency <= 0 {
return errors.New("payload concurrency must be at least 1")
} else {
e.opts.PayloadConcurrency = opts.TemplatePayloadConcurrency
}
if opts.ProbeConcurrency <= 0 {
return errors.New("probe concurrency must be at least 1")
} else {
e.opts.ProbeConcurrency = opts.ProbeConcurrency
}
e.opts.TemplateThreads = opts.TemplateConcurrency
e.opts.BulkSize = opts.HostConcurrency
e.opts.HeadlessBulkSize = opts.HeadlessHostConcurrency
e.opts.HeadlessTemplateThreads = opts.HeadlessTemplateConcurrency
e.opts.JsConcurrency = opts.JavascriptTemplateConcurrency
e.opts.PayloadConcurrency = opts.TemplatePayloadConcurrency
e.opts.ProbeConcurrency = opts.ProbeConcurrency
return nil
}
}

// WithResponseReadSize sets the maximum size of response to read in bytes.
// A value of 0 means no limit. Recommended values: 1MB (1048576) to 10MB (10485760).
func WithResponseReadSize(responseReadSize int) NucleiSDKOptions {
return func(e *NucleiEngine) error {
if responseReadSize < 0 {
return errors.New("response read size must be non-negative")
}
e.opts.ResponseReadSize = responseReadSize
return nil
}
}
Expand Down

0 comments on commit 08c46ff

Please sign in to comment.