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

Fix ExecuteCallbackWithCtx to use the context that was provided #5236

Merged
merged 2 commits into from
May 30, 2024

Conversation

doug-threatmate
Copy link
Contributor

This updates ExecuteCallbackWithCtx to use the context that was provided.

Proposed changes

Recently, context support was added in various places in Nuclei. In particular, ExecuteCallbackWithCtx was added to replace ExecuteCallback. However, the context that is passed in to ExecuteCallbackWithCtx is unused.

This change passes that context along to ExecuteScanWithOpts instead of using context.Background().

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)

This updates `ExecuteCallbackWithCtx` to use the context that was
provided.
@stan-threatmate
Copy link

@tarunKoyalwar this is needed to allow for context cancellation through the SDK.

@GeorginaReeder
Copy link

Thanks so much for your contribution @doug-threatmate , we appreciate it!

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.

thanks for PR and looks like i missed this , after taking a closer look , it seems like there are more hardcoded context especially when creating new RateLimiter in library, i fixed this in this branch but i am getting 403 when i push changes

@doug-threatmate @stan-threatmate , can you give push access to this PR/branch https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

@doug-threatmate
Copy link
Contributor Author

@tarunKoyalwar I don't have the button that your guide references, but I did invite you to the repo, so maybe that'll do the same thing.

@tarunKoyalwar tarunKoyalwar self-requested a review May 30, 2024 10:09
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 !

sorry about the delay , but i have removed all hardcoded contexts in library, this required a change in two public facing functions

NewThreadSafeNucleiEngine(opts ..)
NewNucleiEngine(opts ...)

both of them are now marked as deprecated in favour of

NewThreadSafeNucleiEngineCtx(ctx context.Context,opts ..)
NewNucleiEngineCtx(ctx context.Context, opts ...)

the earlier ones will still work but using those functions is not recommended because if context is cancelled it might cause goroutine leaks

@ehsandeep ehsandeep merged commit 8011012 into projectdiscovery:dev May 30, 2024
12 checks passed
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.

5 participants