Files
nuclei/pkg/tmplexec/flow/util.go
Dwi Siswanto 22b64b6702 fix(flow): segfault in hasMatchers
`hasMatchers` was not nil-safe when iterating over
the slice of operators. Check if the operator is
nil before accessing
`*operators.Operators.Matchers` to prevent a panic
when a protocol implementation returns a slice
containing a nil element.

This can happen when a request has no local
matchers/extractors but is processed in a flow
where global matchers are present.

Fixes #6738.

Signed-off-by: Dwi Siswanto <git@dw1.io>
2025-12-26 14:22:48 +07:00

41 lines
736 B
Go

package flow
import "github.com/projectdiscovery/nuclei/v3/pkg/operators"
// Checks if template has matchers
func hasMatchers(all []*operators.Operators) bool {
for _, operator := range all {
if operator != nil && len(operator.Matchers) > 0 {
return true
}
}
return false
}
// hasOperators checks if template has operators (i.e matchers/extractors)
func hasOperators(all []*operators.Operators) bool {
for _, operator := range all {
if operator != nil {
return true
}
}
return false
}
func flatten(v interface{}) interface{} {
switch v := v.(type) {
case []interface{}:
if len(v) == 1 {
return v[0]
}
return v
case []string:
if len(v) == 1 {
return v[0]
}
return v
default:
return v
}
}