mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 05:25:25 +00:00
2nd race bugfix
This commit is contained in:
parent
ab2f96c9e9
commit
5fa309cb82
@ -306,6 +306,8 @@ func (r *Runner) processTemplateWithList(template *templates.Template, request i
|
||||
return false
|
||||
}
|
||||
|
||||
var globalresult atomicboolean.AtomBool
|
||||
|
||||
var wg sync.WaitGroup
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
@ -323,9 +325,11 @@ func (r *Runner) processTemplateWithList(template *templates.Template, request i
|
||||
|
||||
if httpExecuter != nil {
|
||||
result = httpExecuter.ExecuteHTTP(URL)
|
||||
globalresult.Or(result.GotResults)
|
||||
}
|
||||
if dnsExecuter != nil {
|
||||
result = dnsExecuter.ExecuteDNS(URL)
|
||||
globalresult.Or(result.GotResults)
|
||||
}
|
||||
if result.Error != nil {
|
||||
gologger.Warningf("Could not execute step: %s\n", result.Error)
|
||||
@ -337,16 +341,7 @@ func (r *Runner) processTemplateWithList(template *templates.Template, request i
|
||||
wg.Wait()
|
||||
|
||||
// See if we got any results from the executers
|
||||
var results bool
|
||||
if httpExecuter != nil {
|
||||
results = httpExecuter.Results
|
||||
}
|
||||
if dnsExecuter != nil {
|
||||
if !results {
|
||||
results = dnsExecuter.Results
|
||||
}
|
||||
}
|
||||
return results
|
||||
return globalresult.Get()
|
||||
}
|
||||
|
||||
// ProcessWorkflowWithList coming from stdin or list of targets
|
||||
|
||||
@ -110,7 +110,6 @@ func (e *DNSExecuter) ExecuteDNS(URL string) (result Result) {
|
||||
// write the first output then move to next matcher.
|
||||
if matcherCondition == matchers.ORCondition && len(e.dnsRequest.Extractors) == 0 {
|
||||
e.writeOutputDNS(domain, matcher, nil)
|
||||
e.Results = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,7 +127,6 @@ func (e *DNSExecuter) ExecuteDNS(URL string) (result Result) {
|
||||
// AND or if we have extractors for the mechanism too.
|
||||
if len(e.dnsRequest.Extractors) > 0 || matcherCondition == matchers.ANDCondition {
|
||||
e.writeOutputDNS(domain, nil, extractorResults)
|
||||
e.Results = true
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@ -191,7 +191,6 @@ func (e *HTTPExecuter) handleHTTP(URL string, request *requests.HttpRequest, dyn
|
||||
// probably redundant but ensures we snapshot current payload values when matchers are valid
|
||||
result.Meta = request.Meta
|
||||
e.writeOutputHTTP(request, resp, body, matcher, nil)
|
||||
e.Results = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -215,7 +214,6 @@ func (e *HTTPExecuter) handleHTTP(URL string, request *requests.HttpRequest, dyn
|
||||
// AND or if we have extractors for the mechanism too.
|
||||
if len(e.bulkHttpRequest.Extractors) > 0 || matcherCondition == matchers.ANDCondition {
|
||||
e.writeOutputHTTP(request, resp, body, nil, extractorResults)
|
||||
e.Results = true
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
tengo "github.com/d5/tengo/v2"
|
||||
"github.com/projectdiscovery/gologger"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/atomicboolean"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/executer"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/generators"
|
||||
)
|
||||
@ -50,7 +51,7 @@ func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
|
||||
externalVars = iterableToMap(args[1])
|
||||
}
|
||||
|
||||
var gotResult bool
|
||||
var gotResult atomicboolean.AtomBool
|
||||
for _, template := range n.Templates {
|
||||
if template.HTTPOptions != nil {
|
||||
for _, request := range template.HTTPOptions.Template.BulkRequestsHTTP {
|
||||
@ -70,8 +71,8 @@ func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if httpExecuter.Results {
|
||||
gotResult = true
|
||||
if result.GotResults {
|
||||
gotResult.Or(result.GotResults)
|
||||
n.addResults(&result)
|
||||
}
|
||||
}
|
||||
@ -87,15 +88,15 @@ func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if dnsExecuter.Results {
|
||||
gotResult = true
|
||||
if result.GotResults {
|
||||
gotResult.Or(result.GotResults)
|
||||
n.addResults(&result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if gotResult {
|
||||
if gotResult.Get() {
|
||||
return tengo.TrueValue, nil
|
||||
}
|
||||
return tengo.FalseValue, nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user