mirror of https://github.com/daffainfo/nuclei.git
adding integration tests for single/multiple race conditions requests
parent
2ee74b483b
commit
aec007e1b4
|
@ -0,0 +1,46 @@
|
||||||
|
id: race-condition-testing
|
||||||
|
|
||||||
|
info:
|
||||||
|
name: Race condition testing with multiple requests
|
||||||
|
author: pdteam
|
||||||
|
severity: info
|
||||||
|
|
||||||
|
requests:
|
||||||
|
- raw:
|
||||||
|
- |
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: {{Hostname}}
|
||||||
|
|
||||||
|
id=1
|
||||||
|
|
||||||
|
- |
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: {{Hostname}}
|
||||||
|
|
||||||
|
id=2
|
||||||
|
|
||||||
|
- |
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: {{Hostname}}
|
||||||
|
|
||||||
|
id=3
|
||||||
|
|
||||||
|
- |
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: {{Hostname}}
|
||||||
|
|
||||||
|
id=4
|
||||||
|
|
||||||
|
- |
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: {{Hostname}}
|
||||||
|
|
||||||
|
id=5
|
||||||
|
|
||||||
|
threads: 5
|
||||||
|
race: true
|
||||||
|
|
||||||
|
matchers:
|
||||||
|
- type: status
|
||||||
|
status:
|
||||||
|
- 200
|
|
@ -0,0 +1,23 @@
|
||||||
|
id: race-condition-testing
|
||||||
|
|
||||||
|
info:
|
||||||
|
name: Race Condition testing
|
||||||
|
author: pdteam
|
||||||
|
severity: info
|
||||||
|
|
||||||
|
requests:
|
||||||
|
- raw:
|
||||||
|
- |
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: {{Hostname}}
|
||||||
|
|
||||||
|
test
|
||||||
|
|
||||||
|
race: true
|
||||||
|
race_count: 10
|
||||||
|
|
||||||
|
matchers:
|
||||||
|
- type: status
|
||||||
|
part: header
|
||||||
|
status:
|
||||||
|
- 200
|
|
@ -42,6 +42,8 @@ var httpTestcases = map[string]testutils.TestCase{
|
||||||
"http/get-redirects-chain-headers.yaml": &httpGetRedirectsChainHeaders{},
|
"http/get-redirects-chain-headers.yaml": &httpGetRedirectsChainHeaders{},
|
||||||
"http/dsl-matcher-variable.yaml": &httpDSLVariable{},
|
"http/dsl-matcher-variable.yaml": &httpDSLVariable{},
|
||||||
"http/dsl-functions.yaml": &httpDSLFunctions{},
|
"http/dsl-functions.yaml": &httpDSLFunctions{},
|
||||||
|
"http/race-simple.yaml": &httpRaceSimple{},
|
||||||
|
"http/race-multiple.yaml": &httpRaceMultiple{},
|
||||||
}
|
}
|
||||||
|
|
||||||
type httpInteractshRequest struct{}
|
type httpInteractshRequest struct{}
|
||||||
|
@ -689,3 +691,39 @@ func (h *httpGetRedirectsChainHeaders) Execute(filePath string) error {
|
||||||
|
|
||||||
return expectResultsCount(results, 1)
|
return expectResultsCount(results, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type httpRaceSimple struct{}
|
||||||
|
|
||||||
|
// Execute executes a test case and returns an error if occurred
|
||||||
|
func (h *httpRaceSimple) Execute(filePath string) error {
|
||||||
|
router := httprouter.New()
|
||||||
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
})
|
||||||
|
ts := httptest.NewServer(router)
|
||||||
|
defer ts.Close()
|
||||||
|
|
||||||
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return expectResultsCount(results, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
type httpRaceMultiple struct{}
|
||||||
|
|
||||||
|
// Execute executes a test case and returns an error if occurred
|
||||||
|
func (h *httpRaceMultiple) Execute(filePath string) error {
|
||||||
|
router := httprouter.New()
|
||||||
|
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
})
|
||||||
|
ts := httptest.NewServer(router)
|
||||||
|
defer ts.Close()
|
||||||
|
|
||||||
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return expectResultsCount(results, 5)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue