Skip to content

Commit

Permalink
fix(sdk): NoHostErrors not set (#5783)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuliu8899 authored Jan 2, 2025
1 parent f308c4b commit 258f38f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
15 changes: 14 additions & 1 deletion lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,23 @@ func WithNetworkConfig(opts NetworkConfig) NucleiSDKOptions {
if e.mode == threadSafe {
return ErrOptionsNotSupported.Msgf("WithNetworkConfig")
}
e.opts.NoHostErrors = opts.DisableMaxHostErr
e.opts.MaxHostError = opts.MaxHostError
if e.opts.ShouldUseHostError() {
maxHostError := opts.MaxHostError
if e.opts.TemplateThreads > maxHostError {
gologger.Print().Msgf("[%v] The concurrency value is higher than max-host-error", e.executerOpts.Colorizer.BrightYellow("WRN"))
gologger.Info().Msgf("Adjusting max-host-error to the concurrency value: %d", e.opts.TemplateThreads)
maxHostError = e.opts.TemplateThreads
e.opts.MaxHostError = maxHostError
}
cache := hosterrorscache.New(maxHostError, hosterrorscache.DefaultMaxHostsCount, e.opts.TrackError)
cache.SetVerbose(e.opts.Verbose)
e.hostErrCache = cache
}
e.opts.Timeout = opts.Timeout
e.opts.Retries = opts.Retries
e.opts.LeaveDefaultPorts = opts.LeaveDefaultPorts
e.hostErrCache = hosterrorscache.New(opts.MaxHostError, hosterrorscache.DefaultMaxHostsCount, opts.TrackError)
e.opts.Interface = opts.Interface
e.opts.SourceIP = opts.SourceIP
e.opts.SystemResolvers = opts.SystemResolvers
Expand Down
3 changes: 3 additions & 0 deletions lib/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func createEphemeralObjects(ctx context.Context, base *NucleiEngine, opts *types
Parser: base.parser,
Browser: base.browserInstance,
}
if opts.ShouldUseHostError() && base.hostErrCache != nil {
u.executerOpts.HostErrorsCache = base.hostErrCache
}
if opts.RateLimitMinute > 0 {
opts.RateLimit = opts.RateLimitMinute
opts.RateLimitDuration = time.Minute
Expand Down
30 changes: 16 additions & 14 deletions lib/sdk_private.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (e *NucleiEngine) applyRequiredDefaults(ctx context.Context) {
if e.customProgress == nil {
e.customProgress = &testutils.MockProgressClient{}
}
if e.hostErrCache == nil {
if e.hostErrCache == nil && e.opts.ShouldUseHostError() {
e.hostErrCache = hosterrorscache.New(30, hosterrorscache.DefaultMaxHostsCount, nil)
}
// setup interactsh
Expand Down Expand Up @@ -161,19 +161,21 @@ func (e *NucleiEngine) init(ctx context.Context) error {
}

e.executerOpts = protocols.ExecutorOptions{
Output: e.customWriter,
Options: e.opts,
Progress: e.customProgress,
Catalog: e.catalog,
IssuesClient: e.rc,
RateLimiter: e.rateLimiter,
Interactsh: e.interactshClient,
HostErrorsCache: e.hostErrCache,
Colorizer: aurora.NewAurora(true),
ResumeCfg: types.NewResumeCfg(),
Browser: e.browserInstance,
Parser: e.parser,
InputHelper: input.NewHelper(),
Output: e.customWriter,
Options: e.opts,
Progress: e.customProgress,
Catalog: e.catalog,
IssuesClient: e.rc,
RateLimiter: e.rateLimiter,
Interactsh: e.interactshClient,
Colorizer: aurora.NewAurora(true),
ResumeCfg: types.NewResumeCfg(),
Browser: e.browserInstance,
Parser: e.parser,
InputHelper: input.NewHelper(),
}
if e.opts.ShouldUseHostError() && e.hostErrCache != nil {
e.executerOpts.HostErrorsCache = e.hostErrCache
}
if len(e.opts.SecretsFile) > 0 {
authTmplStore, err := runner.GetAuthTmplStore(*e.opts, e.catalog, e.executerOpts)
Expand Down

0 comments on commit 258f38f

Please sign in to comment.