mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-02-18 00:13:14 +08:00
feat: added support for context cancellation to engine (#5096)
* feat: added support for context cancellation to engine * misc * feat: added contexts everywhere * misc * misc * use granular http timeouts and increase http timeout to 30s using multiplier * track response header timeout in mhe * update responseHeaderTimeout to 5sec * skip failing windows test --------- Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
This commit is contained in:
@@ -55,8 +55,8 @@ func TestFlowTemplateWithIndex(t *testing.T) {
|
||||
err = Template.Executer.Compile()
|
||||
require.Nil(t, err, "could not compile template")
|
||||
|
||||
input := contextargs.NewWithInput("hackerone.com")
|
||||
ctx := scan.NewScanContext(input)
|
||||
input := contextargs.NewWithInput(context.Background(), "hackerone.com")
|
||||
ctx := scan.NewScanContext(context.Background(), input)
|
||||
gotresults, err := Template.Executer.Execute(ctx)
|
||||
require.Nil(t, err, "could not execute template")
|
||||
require.True(t, gotresults)
|
||||
@@ -74,8 +74,8 @@ func TestFlowTemplateWithID(t *testing.T) {
|
||||
err = Template.Executer.Compile()
|
||||
require.Nil(t, err, "could not compile template")
|
||||
|
||||
target := contextargs.NewWithInput("hackerone.com")
|
||||
ctx := scan.NewScanContext(target)
|
||||
target := contextargs.NewWithInput(context.Background(), "hackerone.com")
|
||||
ctx := scan.NewScanContext(context.Background(), target)
|
||||
gotresults, err := Template.Executer.Execute(ctx)
|
||||
require.Nil(t, err, "could not execute template")
|
||||
require.True(t, gotresults)
|
||||
@@ -96,8 +96,8 @@ func TestFlowWithProtoPrefix(t *testing.T) {
|
||||
err = Template.Executer.Compile()
|
||||
require.Nil(t, err, "could not compile template")
|
||||
|
||||
input := contextargs.NewWithInput("hackerone.com")
|
||||
ctx := scan.NewScanContext(input)
|
||||
input := contextargs.NewWithInput(context.Background(), "hackerone.com")
|
||||
ctx := scan.NewScanContext(context.Background(), input)
|
||||
gotresults, err := Template.Executer.Execute(ctx)
|
||||
require.Nil(t, err, "could not execute template")
|
||||
require.True(t, gotresults)
|
||||
@@ -116,8 +116,8 @@ func TestFlowWithConditionNegative(t *testing.T) {
|
||||
err = Template.Executer.Compile()
|
||||
require.Nil(t, err, "could not compile template")
|
||||
|
||||
input := contextargs.NewWithInput("scanme.sh")
|
||||
ctx := scan.NewScanContext(input)
|
||||
input := contextargs.NewWithInput(context.Background(), "scanme.sh")
|
||||
ctx := scan.NewScanContext(context.Background(), input)
|
||||
// expect no results and verify thant dns request is executed and http is not
|
||||
gotresults, err := Template.Executer.Execute(ctx)
|
||||
require.Nil(t, err, "could not execute template")
|
||||
@@ -137,8 +137,8 @@ func TestFlowWithConditionPositive(t *testing.T) {
|
||||
err = Template.Executer.Compile()
|
||||
require.Nil(t, err, "could not compile template")
|
||||
|
||||
input := contextargs.NewWithInput("blog.projectdiscovery.io")
|
||||
ctx := scan.NewScanContext(input)
|
||||
input := contextargs.NewWithInput(context.Background(), "blog.projectdiscovery.io")
|
||||
ctx := scan.NewScanContext(context.Background(), input)
|
||||
// positive match . expect results also verify that both dns() and http() were executed
|
||||
gotresults, err := Template.Executer.Execute(ctx)
|
||||
require.Nil(t, err, "could not execute template")
|
||||
@@ -158,8 +158,8 @@ func TestFlowWithNoMatchers(t *testing.T) {
|
||||
err = Template.Executer.Compile()
|
||||
require.Nil(t, err, "could not compile template")
|
||||
|
||||
input := contextargs.NewWithInput("blog.projectdiscovery.io")
|
||||
ctx := scan.NewScanContext(input)
|
||||
input := contextargs.NewWithInput(context.Background(), "blog.projectdiscovery.io")
|
||||
ctx := scan.NewScanContext(context.Background(), input)
|
||||
// positive match . expect results also verify that both dns() and http() were executed
|
||||
gotresults, err := Template.Executer.Execute(ctx)
|
||||
require.Nil(t, err, "could not execute template")
|
||||
@@ -174,8 +174,8 @@ func TestFlowWithNoMatchers(t *testing.T) {
|
||||
err = Template.Executer.Compile()
|
||||
require.Nil(t, err, "could not compile template")
|
||||
|
||||
anotherInput := contextargs.NewWithInput("blog.projectdiscovery.io")
|
||||
anotherCtx := scan.NewScanContext(anotherInput)
|
||||
anotherInput := contextargs.NewWithInput(context.Background(), "blog.projectdiscovery.io")
|
||||
anotherCtx := scan.NewScanContext(context.Background(), anotherInput)
|
||||
// positive match . expect results also verify that both dns() and http() were executed
|
||||
gotresults, err = Template.Executer.Execute(anotherCtx)
|
||||
require.Nil(t, err, "could not execute template")
|
||||
|
||||
Reference in New Issue
Block a user