-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: enforce global timeout using context.WithTimeout #1629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Runner
participant EnumerationProcess
Caller->>Runner: RunEnumerationWithCtx(ctx)
Runner->>Runner: Create timeout context (WithTimeout)
Runner->>EnumerationProcess: Start enumeration with timeout context
EnumerationProcess-->>Runner: Complete or timeout
Runner->>Runner: Defer cancel()
Runner-->>Caller: Return result or context error
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Assessment against linked issues
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (2)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Mzack9999
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Failing tests
- Left a question related to global timeout
|
|
||
| // RunEnumerationWithCtx runs the subdomain enumeration flow on the targets specified | ||
| func (r *Runner) RunEnumerationWithCtx(ctx context.Context) error { | ||
| timeout := time.Duration(r.options.Timeout) * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the intended functionality, as the timeout setting like in other tools is applied to each individual request
Fixes #1560
Problem
The
-timeoutflag was inconsistently enforced across different runs. Although HTTP clients respected the timeout value, the overall enumeration process was not constrained, causing long or indefinite execution when sources delayed or hung.Root Cause
The CLI-level
-timeoutvalue was not applied to the root execution context (RunEnumerationWithCtx). As a result, even if individual HTTP requests timed out, the global orchestration layer continued waiting for results.Changes
RunEnumerationWithCtxwithcontext.WithTimeoutusing the configuredr.options.TimeoutResult
Before:
After:
Sources that do not return within the timeout window are safely cancelled, resulting in consistent timing.
Summary by CodeRabbit