2021-01-13 03:17:07 +05:30
|
|
|
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.
|
|
|
|
|
func (r *Request) CanCluster(other *Request) bool {
|
2021-06-03 10:26:41 +05:30
|
|
|
if len(r.Payloads) > 0 || len(r.Raw) > 0 || len(r.Body) > 0 || r.Unsafe || r.ReqCondition || r.Name != "" {
|
2021-01-13 03:17:07 +05:30
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if r.Method != other.Method ||
|
|
|
|
|
r.MaxRedirects != other.MaxRedirects ||
|
|
|
|
|
r.CookieReuse != other.CookieReuse ||
|
|
|
|
|
r.Redirects != other.Redirects {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if !compare.StringSlice(r.Path, other.Path) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if !compare.StringMap(r.Headers, other.Headers) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|