2021-01-12 21:47:07 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/compare"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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 11:30:04 +00:00
|
|
|
func (request *Request) CanCluster(other *Request) bool {
|
|
|
|
if len(request.Payloads) > 0 || len(request.Raw) > 0 || len(request.Body) > 0 || request.Unsafe || request.ReqCondition || request.Name != "" {
|
2021-01-12 21:47:07 +00:00
|
|
|
return false
|
|
|
|
}
|
2021-10-01 11:30:04 +00:00
|
|
|
if request.Method != other.Method ||
|
|
|
|
request.MaxRedirects != other.MaxRedirects ||
|
|
|
|
request.CookieReuse != other.CookieReuse ||
|
|
|
|
request.Redirects != other.Redirects {
|
2021-01-12 21:47:07 +00:00
|
|
|
return false
|
|
|
|
}
|
2021-10-01 11:30:04 +00:00
|
|
|
if !compare.StringSlice(request.Path, other.Path) {
|
2021-01-12 21:47:07 +00:00
|
|
|
return false
|
|
|
|
}
|
2021-10-01 11:30:04 +00:00
|
|
|
if !compare.StringMap(request.Headers, other.Headers) {
|
2021-01-12 21:47:07 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|