Skip to content
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

introduce timeouts config in types.Options #5228

Merged
merged 8 commits into from
Jul 15, 2024
Merged

Conversation

dogancanbakir
Copy link
Member

Proposed changes

Closes #5214

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@dogancanbakir dogancanbakir self-assigned this May 27, 2024
Copy link
Member

@tarunKoyalwar tarunKoyalwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like there are more hardcoded timeouts apart from the existing ones i think it would be great to update these as well

	// execute with context and timeout
	ctx, cancel := context.WithTimeoutCause(opts.Context, time.Duration(opts.Timeout)*time.Second, ErrJSExecDeadline)
	defer cancel()

^ in js/compiler/compiler.go this should be equal to JsCompilerExecTimeout

	ctx, cancel := context.WithTimeoutCause(input.Context(), time.Duration(timeout)*time.Second, ErrCodeExecutionDeadline)
	defer cancel()

^ code protocol i think we intended code protocol timeout to be 3 x -timeout

  • derive pageTimeout from timeout variants ( ideally 3 * -timeout )

  • improve flag description of -irt, -input-read-timeout value i thought it was related to network protocol but it is actually a timeout for stdin read

pkg/types/types.go Outdated Show resolved Hide resolved
Copy link
Member

@tarunKoyalwar tarunKoyalwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes + merge conflict + test failure

@tarunKoyalwar tarunKoyalwar changed the title introduce timeout variants introduce timeouts config in types.Options Jul 8, 2024
Copy link
Member

@tarunKoyalwar tarunKoyalwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm !

now all timeouts are stored in Timeouts struct which is pluggable ( not required and derived from -timeout but can manually be specified via SDK for more control ) .

All Known Timeouts and their default values

// Timeouts is a struct that contains all the timeout variants for nuclei
// dialer timeout is used to derive other timeouts
type Timeouts struct {
	// DialTimeout for fastdialer (default 10s)
	DialTimeout time.Duration
	// Tcp(Network Protocol) Read From Connection Timeout (default 5s)
	TcpReadTimeout time.Duration
	// Http Response Header Timeout (default 10s)
	// this timeout prevents infinite hangs started by server if any
	// this is temporarily overridden when using @timeout request annotation
	HttpResponseHeaderTimeout time.Duration
	// HttpTimeout for http client (default -> 3 x dial-timeout = 30s)
	HttpTimeout time.Duration
	// JsCompilerExec timeout/deadline (default -> 2 x dial-timeout = 20s)
	JsCompilerExecutionTimeout time.Duration
	// CodeExecutionTimeout for code execution (default -> 3 x dial-timeout = 30s)
	CodeExecutionTimeout time.Duration
}

Caution

This change removes below cli flags

 -dt, -dialer-timeout value  timeout for network requests.
 -rrt, -response-read-timeout value  response read timeout in seconds (default 5s)

@tarunKoyalwar tarunKoyalwar requested a review from ehsandeep July 8, 2024 12:01
@ehsandeep ehsandeep merged commit f080d61 into dev Jul 15, 2024
12 checks passed
@ehsandeep ehsandeep deleted the introduce_timeout_variants branch July 15, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Group all timeouts in nuclei to single struct and derive from single value
3 participants