Fix(clientpool): remove global variable from clientpool in favour for local variable#7294
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
WalkthroughRemoved package-level mutable Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/protocols/http/httpclientpool/clientpool.go`:
- Around line 216-225: The code unconditionally overwrites the request/template
redirect cap by assigning maxRedirects = options.MaxRedirects even when
options.MaxRedirects is the unset/default (0). Change the assignment so
maxRedirects is only replaced when options.MaxRedirects is set (non-zero/greater
than 0), preserving the existing configuration.MaxRedirects/request-level cap
otherwise; keep the redirectFlow logic the same and let checkMaxRedirects()
continue to enforce the final cap.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c047238b-f46a-42da-a0a8-ef4019ca6975
📒 Files selected for processing (1)
pkg/protocols/http/httpclientpool/clientpool.go
Neo - PR Security ReviewNo security issues found Highlights
Comment |
f0d5eff to
49a0ffe
Compare
Proposed changes
When multiple instances of nuclei SDK are initialized, the
clientpool.Init()function is called multiple times, leading to unexpected/overwrite behavior in thewrapperGetfunction.Since the
wrapperGetfunction already has access to the options, there is little reason to initialize this variable globally, and it can just be done in thewrapperGetfunc.Flow changes
Based on this change, the flow also is slightly changed, before hand, it would only follow redirects if the option
options.MaxRedirects> 0 (and thus ignore theFollowHostRedirectsandFollowRedirectsoptions if it was == 0.Now if
max(options.MaxRedirects, configuration.MaxRedirects) > 0it will follow redirects (aka honoring the options).Proof
Checklist
Summary by CodeRabbit