nuclei
nuclei copied to clipboard
[Library] Take a context for cancellation
Please describe your feature request:
The function core.Execute should take a context.Context
parameter and cancel the execution when the context is cancelled.
https://github.com/projectdiscovery/nuclei/blob/1f9a065713924b28b203e2108fc76d7a1ec49068/v2/pkg/core/executors.go#L208
The current CLI implementation bypass this limitation by calling os.Exit(1)
to stop the running process:
https://github.com/projectdiscovery/nuclei/blob/1f9a065713924b28b203e2108fc76d7a1ec49068/v2/cmd/nuclei/main.go#L81-L99
The runner.Close()
function is a bit misleading because it does not really close all resources:
https://github.com/projectdiscovery/nuclei/blob/1f9a065713924b28b203e2108fc76d7a1ec49068/v2/internal/runner/runner.go#L377-L378
It doesn't close / stops the running core.ChildExecuter
s.
Describe the use case of this feature:
This would be needed to use Nuclei as a library with timeout and cancellation.
This will be useful. I'd like to embed nuclei as a library and be able to cancel it at any time.
Fixed by https://github.com/projectdiscovery/nuclei/pull/5096