github.com/projectdiscovery/nuclei/v2@v2.9.15/pkg/protocols/http/request_condition.go (about) 1 package http 2 3 import ( 4 "regexp" 5 ) 6 7 var ( 8 // Determines if request condition are needed by detecting the pattern _xxx 9 reRequestCondition = regexp.MustCompile(`(?m)_\d+`) 10 ) 11 12 // NeedsRequestCondition determines if request condition should be enabled 13 func (request *Request) NeedsRequestCondition() bool { 14 for _, matcher := range request.Matchers { 15 if checkRequestConditionExpressions(matcher.DSL...) { 16 return true 17 } 18 if checkRequestConditionExpressions(matcher.Part) { 19 return true 20 } 21 } 22 for _, extractor := range request.Extractors { 23 if checkRequestConditionExpressions(extractor.DSL...) { 24 return true 25 } 26 if checkRequestConditionExpressions(extractor.Part) { 27 return true 28 } 29 } 30 31 return false 32 } 33 34 func checkRequestConditionExpressions(expressions ...string) bool { 35 for _, expression := range expressions { 36 if reRequestCondition.MatchString(expression) { 37 return true 38 } 39 } 40 return false 41 }