2021-01-13 03:17:07 +05:30
|
|
|
package http
|
|
|
|
|
|
|
|
|
|
import (
|
2023-09-13 18:57:48 +02:00
|
|
|
sliceutil "github.com/projectdiscovery/utils/slice"
|
|
|
|
|
"golang.org/x/exp/maps"
|
2021-01-13 03:17:07 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// CanCluster returns true if the request can be clustered.
|
|
|
|
|
//
|
|
|
|
|
// This used by the clustering engine to decide whether two requests
|
|
|
|
|
// are similar enough to be considered one and can be checked by
|
|
|
|
|
// just adding the matcher/extractors for the request and the correct IDs.
|
2021-10-01 14:30:04 +03:00
|
|
|
func (request *Request) CanCluster(other *Request) bool {
|
2022-12-05 23:07:38 +05:30
|
|
|
if len(request.Payloads) > 0 || len(request.Fuzzing) > 0 || len(request.Raw) > 0 || len(request.Body) > 0 || request.Unsafe || request.NeedsRequestCondition() || request.Name != "" {
|
2021-01-13 03:17:07 +05:30
|
|
|
return false
|
|
|
|
|
}
|
2021-10-01 14:30:04 +03:00
|
|
|
if request.Method != other.Method ||
|
|
|
|
|
request.MaxRedirects != other.MaxRedirects ||
|
2023-11-18 10:32:10 +03:00
|
|
|
request.DisableCookie != other.DisableCookie ||
|
2021-10-01 14:30:04 +03:00
|
|
|
request.Redirects != other.Redirects {
|
2021-01-13 03:17:07 +05:30
|
|
|
return false
|
|
|
|
|
}
|
2023-09-13 18:57:48 +02:00
|
|
|
if !sliceutil.Equal(request.Path, other.Path) {
|
2021-01-13 03:17:07 +05:30
|
|
|
return false
|
|
|
|
|
}
|
2023-09-13 18:57:48 +02:00
|
|
|
if !maps.Equal(request.Headers, other.Headers) {
|
2021-01-13 03:17:07 +05:30
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|