mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 14:35:26 +00:00
added support for multiple raw requests
This commit is contained in:
parent
f5b6474a11
commit
ec7cd50e22
@ -39,8 +39,8 @@ type HTTPRequest struct {
|
||||
Redirects bool `yaml:"redirects,omitempty"`
|
||||
// MaxRedirects is the maximum number of redirects that should be followed.
|
||||
MaxRedirects int `yaml:"max-redirects,omitempty"`
|
||||
// Raw contains a raw request
|
||||
Raw string `yaml:"raw,omitempty"`
|
||||
// Raw contains raw requests
|
||||
Raw []string `yaml:"raw,omitempty"`
|
||||
}
|
||||
|
||||
// GetMatchersCondition returns the condition for the matcher
|
||||
@ -66,7 +66,7 @@ func (r *HTTPRequest) MakeHTTPRequest(baseURL string) ([]*retryablehttp.Request,
|
||||
"Hostname": hostname,
|
||||
}
|
||||
|
||||
if r.Raw != "" {
|
||||
if len(r.Raw) > 0 {
|
||||
return r.makeHTTPRequestFromRaw(baseURL, values)
|
||||
}
|
||||
|
||||
@ -98,9 +98,13 @@ func (r *HTTPRequest) makeHTTPRequestFromModel(baseURL string, values map[string
|
||||
}
|
||||
|
||||
// makeHTTPRequestFromRaw creates a *http.Request from a raw request
|
||||
func (r *HTTPRequest) makeHTTPRequestFromRaw(baseURL string, values map[string]interface{}) ([]*retryablehttp.Request, error) {
|
||||
func (r *HTTPRequest) makeHTTPRequestFromRaw(baseURL string, values map[string]interface{}) (requests []*retryablehttp.Request, err error) {
|
||||
for _, raw := range r.Raw {
|
||||
// Add trailing line
|
||||
raw += "\n"
|
||||
|
||||
// Replace the dynamic variables in the URL if any
|
||||
t := fasttemplate.New(r.Raw, "{{", "}}")
|
||||
t := fasttemplate.New(raw, "{{", "}}")
|
||||
raw := t.ExecuteString(values)
|
||||
|
||||
// Build a parsed request from raw
|
||||
@ -126,7 +130,10 @@ func (r *HTTPRequest) makeHTTPRequestFromRaw(baseURL string, values map[string]i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return []*retryablehttp.Request{request}, nil
|
||||
requests = append(requests, request)
|
||||
}
|
||||
|
||||
return requests, nil
|
||||
}
|
||||
|
||||
func (r *HTTPRequest) fillRequest(req *http.Request, values map[string]interface{}) (*retryablehttp.Request, error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user