mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 04:45:27 +00:00
Adding offline http tests (#2276)
This commit is contained in:
parent
1c332bb85b
commit
57b2ec7ade
18
integration_tests/offlinehttp/offline-allowed-paths.yaml
Normal file
18
integration_tests/offlinehttp/offline-allowed-paths.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
id: offline-allowed-paths
|
||||
|
||||
info:
|
||||
name: offline-allowed-paths
|
||||
author: pdteam
|
||||
severity: info
|
||||
description: offline-allowed-paths
|
||||
|
||||
requests:
|
||||
- path:
|
||||
- "{{BaseURL}}"
|
||||
- "{{BaseURL}}/"
|
||||
- "/"
|
||||
|
||||
matchers:
|
||||
- type: status
|
||||
status:
|
||||
- 200
|
||||
16
integration_tests/offlinehttp/offline-raw.yaml
Normal file
16
integration_tests/offlinehttp/offline-raw.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
id: offline-raw
|
||||
info:
|
||||
name: Test Offline raw Template
|
||||
author: pdteam
|
||||
severity: info
|
||||
|
||||
requests:
|
||||
- raw:
|
||||
- |
|
||||
GET / HTTP/1.1
|
||||
Host: {{Hostname}}
|
||||
|
||||
matchers:
|
||||
- type: status
|
||||
status:
|
||||
- 200
|
||||
@ -1,11 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
||||
)
|
||||
|
||||
var offlineHttpTestcases = map[string]testutils.TestCase{
|
||||
"offlinehttp/rfc-req-resp.yaml": &RfcRequestResponse{},
|
||||
"offlinehttp/rfc-req-resp.yaml": &RfcRequestResponse{},
|
||||
"offlinehttp/offline-allowed-paths.yaml": &RequestResponseWithAllowedPaths{},
|
||||
"offlinehttp/offline-raw.yaml": &RawRequestResponse{},
|
||||
}
|
||||
|
||||
type RfcRequestResponse struct{}
|
||||
@ -19,3 +23,26 @@ func (h *RfcRequestResponse) Execute(filePath string) error {
|
||||
|
||||
return expectResultsCount(results, 1)
|
||||
}
|
||||
|
||||
type RequestResponseWithAllowedPaths struct{}
|
||||
|
||||
// Execute executes a test case and returns an error if occurred
|
||||
func (h *RequestResponseWithAllowedPaths) Execute(filePath string) error {
|
||||
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "offlinehttp/data/", debug, "-passive")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return expectResultsCount(results, 1)
|
||||
}
|
||||
|
||||
type RawRequestResponse struct{}
|
||||
|
||||
// Execute executes a test case and returns an error if occurred
|
||||
func (h *RawRequestResponse) Execute(filePath string) error {
|
||||
_, err := testutils.RunNucleiTemplateAndGetResults(filePath, "offlinehttp/data/", debug, "-passive")
|
||||
if err == nil {
|
||||
return fmt.Errorf("incorrect result: no error (actual) vs error expected")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user