diff --git a/integration_tests/headless/file-upload-negative.yaml b/integration_tests/headless/file-upload-negative.yaml new file mode 100644 index 000000000..3d8c2bf4a --- /dev/null +++ b/integration_tests/headless/file-upload-negative.yaml @@ -0,0 +1,29 @@ +id: file-upload +# template for testing when file upload is disabled +info: + name: Basic File Upload + author: pdteam + severity: info + +headless: + - steps: + - action: navigate + args: + url: "{{BaseURL}}" + - action: waitload + - action: files + args: + by: xpath + xpath: /html/body/form/input[1] + value: headless/file-upload.yaml + - action: sleep + args: + duration: 2 + - action: click + args: + by: x + xpath: /html/body/form/input[2] + matchers: + - type: word + words: + - "Basic File Upload" \ No newline at end of file diff --git a/integration_tests/headless/headless-local.yaml b/integration_tests/headless/headless-local.yaml new file mode 100644 index 000000000..385859d0a --- /dev/null +++ b/integration_tests/headless/headless-local.yaml @@ -0,0 +1,15 @@ +id: nuclei-headless-local + +info: + name: Nuclei Headless Local + author: pdteam + severity: high + +headless: + - steps: + - action: navigate + args: + url: "{{BaseURL}}" + + - action: waitload + \ No newline at end of file diff --git a/v2/cmd/integration-test/headless.go b/v2/cmd/integration-test/headless.go index 185cdc87f..b30c464cc 100644 --- a/v2/cmd/integration-test/headless.go +++ b/v2/cmd/integration-test/headless.go @@ -16,7 +16,9 @@ var headlessTestcases = []TestCaseInfo{ {Path: "headless/headless-extract-values.yaml", TestCase: &headlessExtractValues{}}, {Path: "headless/headless-payloads.yaml", TestCase: &headlessPayloads{}}, {Path: "headless/variables.yaml", TestCase: &headlessVariables{}}, + {Path: "headless/headless-local.yaml", TestCase: &headlessLocal{}}, {Path: "headless/file-upload.yaml", TestCase: &headlessFileUpload{}}, + {Path: "headless/file-upload-negative.yaml", TestCase: &headlessFileUploadNegative{}}, {Path: "headless/headless-header-status-test.yaml", TestCase: &headlessHeaderStatus{}}, } @@ -39,6 +41,27 @@ func (h *headlessBasic) Execute(filePath string) error { return expectResultsCount(results, 1) } +type headlessLocal struct{} + +// Execute executes a test case and returns an error if occurred +// in this testcases local network access is disabled +func (h *headlessLocal) Execute(filePath string) error { + router := httprouter.New() + router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + _, _ = w.Write([]byte("
")) + }) + ts := httptest.NewServer(router) + defer ts.Close() + + args := []string{"-t", filePath, "-u", ts.URL, "-headless", "-lna"} + + results, err := testutils.RunNucleiWithArgsAndGetResults(debug, args...) + if err != nil { + return err + } + return expectResultsCount(results, 0) +} + type headlessHeaderActions struct{} // Execute executes a test case and returns an error if occurred @@ -171,3 +194,48 @@ func (h *headlessHeaderStatus) Execute(filePath string) error { return expectResultsCount(results, 1) } + +type headlessFileUploadNegative struct{} + +// Execute executes a test case and returns an error if occurred +func (h *headlessFileUploadNegative) Execute(filePath string) error { + router := httprouter.New() + router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + _, _ = w.Write([]byte(` + + + + +