forked from projectdiscovery/nuclei
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest_condition.go
More file actions
37 lines (32 loc) · 874 Bytes
/
request_condition.go
File metadata and controls
37 lines (32 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package http
import (
"regexp"
"slices"
)
var (
// Determines if request condition are needed by detecting the pattern _xxx
reRequestCondition = regexp.MustCompile(`(?m)_\d+`)
)
// NeedsRequestCondition determines if request condition should be enabled
func (request *Request) NeedsRequestCondition() bool {
for _, matcher := range request.Matchers {
if checkRequestConditionExpressions(matcher.DSL...) {
return true
}
if checkRequestConditionExpressions(matcher.Part) {
return true
}
}
for _, extractor := range request.Extractors {
if checkRequestConditionExpressions(extractor.DSL...) {
return true
}
if checkRequestConditionExpressions(extractor.Part) {
return true
}
}
return false
}
func checkRequestConditionExpressions(expressions ...string) bool {
return slices.ContainsFunc(expressions, reRequestCondition.MatchString)
}