mirror of https://github.com/daffainfo/nuclei.git
Misc changes to http request execution with variables
parent
0541040e6b
commit
4669ee22ce
|
@ -243,6 +243,10 @@ func (r *Request) ExecuteWithResults(reqURL string, dynamicValues, previous outp
|
||||||
callback(event)
|
callback(event)
|
||||||
}
|
}
|
||||||
}, requestCount)
|
}, requestCount)
|
||||||
|
// If a variable is unresolved, skip all further requests
|
||||||
|
if err == errStopExecution {
|
||||||
|
break
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if r.options.HostErrorsCache != nil && r.options.HostErrorsCache.CheckError(err) {
|
if r.options.HostErrorsCache != nil && r.options.HostErrorsCache.CheckError(err) {
|
||||||
r.options.HostErrorsCache.MarkFailed(reqURL)
|
r.options.HostErrorsCache.MarkFailed(reqURL)
|
||||||
|
@ -252,8 +256,8 @@ func (r *Request) ExecuteWithResults(reqURL string, dynamicValues, previous outp
|
||||||
requestCount++
|
requestCount++
|
||||||
r.options.Progress.IncrementRequests()
|
r.options.Progress.IncrementRequests()
|
||||||
|
|
||||||
|
// If this was a match and we want to stop at first match, skip all further requests.
|
||||||
if (request.original.options.Options.StopAtFirstMatch || r.StopAtFirstMatch) && gotOutput {
|
if (request.original.options.Options.StopAtFirstMatch || r.StopAtFirstMatch) && gotOutput {
|
||||||
r.options.Progress.IncrementErrorsBy(int64(generator.Total()))
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,6 +266,8 @@ func (r *Request) ExecuteWithResults(reqURL string, dynamicValues, previous outp
|
||||||
|
|
||||||
const drainReqSize = int64(8 * 1024)
|
const drainReqSize = int64(8 * 1024)
|
||||||
|
|
||||||
|
var errStopExecution = errors.New("stop execution due to unresolved variables")
|
||||||
|
|
||||||
// executeRequest executes the actual generated request and returns error if occurred
|
// executeRequest executes the actual generated request and returns error if occurred
|
||||||
func (r *Request) executeRequest(reqURL string, request *generatedRequest, previous output.InternalEvent, hasInteractMarkers bool, callback protocols.OutputEventCallback, requestCount int) error {
|
func (r *Request) executeRequest(reqURL string, request *generatedRequest, previous output.InternalEvent, hasInteractMarkers bool, callback protocols.OutputEventCallback, requestCount int) error {
|
||||||
r.setCustomHeaders(request)
|
r.setCustomHeaders(request)
|
||||||
|
@ -285,7 +291,7 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, previ
|
||||||
// Check if are there any unresolved variables. If yes, skip unless overriden by user.
|
// Check if are there any unresolved variables. If yes, skip unless overriden by user.
|
||||||
if varErr := expressions.ContainsUnresolvedVariables(dumpedRequestString); varErr != nil && !r.SkipVariablesCheck {
|
if varErr := expressions.ContainsUnresolvedVariables(dumpedRequestString); varErr != nil && !r.SkipVariablesCheck {
|
||||||
gologger.Warning().Msgf("[%s] Could not make http request for %s: %v\n", r.options.TemplateID, reqURL, varErr)
|
gologger.Warning().Msgf("[%s] Could not make http request for %s: %v\n", r.options.TemplateID, reqURL, varErr)
|
||||||
return nil
|
return errStopExecution
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.options.Options.Debug || r.options.Options.DebugRequests {
|
if r.options.Options.Debug || r.options.Options.DebugRequests {
|
||||||
|
|
Loading…
Reference in New Issue