Skip to content

Commit 258f38f

Browse files
authored
fix(sdk): NoHostErrors not set (#5783)
1 parent f308c4b commit 258f38f

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

lib/config.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,23 @@ func WithNetworkConfig(opts NetworkConfig) NucleiSDKOptions {
286286
if e.mode == threadSafe {
287287
return ErrOptionsNotSupported.Msgf("WithNetworkConfig")
288288
}
289+
e.opts.NoHostErrors = opts.DisableMaxHostErr
290+
e.opts.MaxHostError = opts.MaxHostError
291+
if e.opts.ShouldUseHostError() {
292+
maxHostError := opts.MaxHostError
293+
if e.opts.TemplateThreads > maxHostError {
294+
gologger.Print().Msgf("[%v] The concurrency value is higher than max-host-error", e.executerOpts.Colorizer.BrightYellow("WRN"))
295+
gologger.Info().Msgf("Adjusting max-host-error to the concurrency value: %d", e.opts.TemplateThreads)
296+
maxHostError = e.opts.TemplateThreads
297+
e.opts.MaxHostError = maxHostError
298+
}
299+
cache := hosterrorscache.New(maxHostError, hosterrorscache.DefaultMaxHostsCount, e.opts.TrackError)
300+
cache.SetVerbose(e.opts.Verbose)
301+
e.hostErrCache = cache
302+
}
289303
e.opts.Timeout = opts.Timeout
290304
e.opts.Retries = opts.Retries
291305
e.opts.LeaveDefaultPorts = opts.LeaveDefaultPorts
292-
e.hostErrCache = hosterrorscache.New(opts.MaxHostError, hosterrorscache.DefaultMaxHostsCount, opts.TrackError)
293306
e.opts.Interface = opts.Interface
294307
e.opts.SourceIP = opts.SourceIP
295308
e.opts.SystemResolvers = opts.SystemResolvers

lib/multi.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ func createEphemeralObjects(ctx context.Context, base *NucleiEngine, opts *types
4242
Parser: base.parser,
4343
Browser: base.browserInstance,
4444
}
45+
if opts.ShouldUseHostError() && base.hostErrCache != nil {
46+
u.executerOpts.HostErrorsCache = base.hostErrCache
47+
}
4548
if opts.RateLimitMinute > 0 {
4649
opts.RateLimit = opts.RateLimitMinute
4750
opts.RateLimitDuration = time.Minute

lib/sdk_private.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (e *NucleiEngine) applyRequiredDefaults(ctx context.Context) {
7373
if e.customProgress == nil {
7474
e.customProgress = &testutils.MockProgressClient{}
7575
}
76-
if e.hostErrCache == nil {
76+
if e.hostErrCache == nil && e.opts.ShouldUseHostError() {
7777
e.hostErrCache = hosterrorscache.New(30, hosterrorscache.DefaultMaxHostsCount, nil)
7878
}
7979
// setup interactsh
@@ -161,19 +161,21 @@ func (e *NucleiEngine) init(ctx context.Context) error {
161161
}
162162

163163
e.executerOpts = protocols.ExecutorOptions{
164-
Output: e.customWriter,
165-
Options: e.opts,
166-
Progress: e.customProgress,
167-
Catalog: e.catalog,
168-
IssuesClient: e.rc,
169-
RateLimiter: e.rateLimiter,
170-
Interactsh: e.interactshClient,
171-
HostErrorsCache: e.hostErrCache,
172-
Colorizer: aurora.NewAurora(true),
173-
ResumeCfg: types.NewResumeCfg(),
174-
Browser: e.browserInstance,
175-
Parser: e.parser,
176-
InputHelper: input.NewHelper(),
164+
Output: e.customWriter,
165+
Options: e.opts,
166+
Progress: e.customProgress,
167+
Catalog: e.catalog,
168+
IssuesClient: e.rc,
169+
RateLimiter: e.rateLimiter,
170+
Interactsh: e.interactshClient,
171+
Colorizer: aurora.NewAurora(true),
172+
ResumeCfg: types.NewResumeCfg(),
173+
Browser: e.browserInstance,
174+
Parser: e.parser,
175+
InputHelper: input.NewHelper(),
176+
}
177+
if e.opts.ShouldUseHostError() && e.hostErrCache != nil {
178+
e.executerOpts.HostErrorsCache = e.hostErrCache
177179
}
178180
if len(e.opts.SecretsFile) > 0 {
179181
authTmplStore, err := runner.GetAuthTmplStore(*e.opts, e.catalog, e.executerOpts)

0 commit comments

Comments
 (0)