Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/protocols/http/cluster.go
2070 views
1
package http
2
3
import (
4
"fmt"
5
"strings"
6
7
"github.com/cespare/xxhash"
8
"github.com/projectdiscovery/nuclei/v3/pkg/utils"
9
)
10
11
// TmplClusterKey generates a unique key for the request
12
// to be used in the clustering process.
13
func (request *Request) TmplClusterKey() uint64 {
14
inp := fmt.Sprintf("%s-%d-%t-%t-%s-%d", request.Method.String(), request.MaxRedirects, request.DisableCookie, request.Redirects, strings.Join(request.Path, "-"), utils.MapHash(request.Headers))
15
return xxhash.Sum64String(inp)
16
}
17
18
// IsClusterable returns true if the request is eligible to be clustered.
19
func (request *Request) IsClusterable() bool {
20
//nolint
21
return !(len(request.Payloads) > 0 || len(request.Fuzzing) > 0 || len(request.Raw) > 0 || len(request.Body) > 0 || request.Unsafe || request.NeedsRequestCondition() || request.Name != "")
22
}
23
24