Files
nuclei/pkg/tmplexec/flow/util_test.go
Dwi Siswanto 8b3485abff test(flow): add util tests
Signed-off-by: Dwi Siswanto <git@dw1.io>
2025-12-26 14:11:43 +07:00

35 lines
1.0 KiB
Go

package flow
import (
"testing"
"github.com/projectdiscovery/nuclei/v3/pkg/operators"
"github.com/stretchr/testify/require"
)
func TestHasMatchersPanicRegression(t *testing.T) {
// This test ensures that hasMatchers does not panic when passed a slice containing nil.
// This was the source of a reported panic when a request had no local operators.
require.NotPanics(t, func() {
all := []*operators.Operators{nil}
result := hasMatchers(all)
require.False(t, result)
}, "hasMatchers should not panic with nil element in slice")
require.NotPanics(t, func() {
all := []*operators.Operators{nil, {}}
result := hasMatchers(all)
require.False(t, result)
}, "hasMatchers should not panic with mix of nil and empty operators")
}
func TestHasOperatorsPanicRegression(t *testing.T) {
// Also ensure hasOperators is safe
require.NotPanics(t, func() {
all := []*operators.Operators{nil}
result := hasOperators(all)
require.False(t, result)
}, "hasOperators should not panic with nil element in slice")
}