2022-11-01 20:28:50 +05:30
|
|
|
package fuzz
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
2023-06-26 19:25:51 +02:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/contextargs"
|
2022-11-01 20:28:50 +05:30
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestRuleIsExecutable(t *testing.T) {
|
|
|
|
|
rule := &Rule{Part: "query"}
|
|
|
|
|
err := rule.Compile(nil, nil)
|
|
|
|
|
require.NoError(t, err, "could not compile rule")
|
|
|
|
|
|
2023-06-26 19:25:51 +02:00
|
|
|
input := contextargs.NewWithInput("https://example.com/?url=localhost")
|
|
|
|
|
result := rule.isExecutable(input)
|
2022-11-01 20:28:50 +05:30
|
|
|
require.True(t, result, "could not get correct result")
|
|
|
|
|
|
2023-06-26 19:25:51 +02:00
|
|
|
input = contextargs.NewWithInput("https://example.com/")
|
|
|
|
|
result = rule.isExecutable(input)
|
2022-11-01 20:28:50 +05:30
|
|
|
require.False(t, result, "could not get correct result")
|
|
|
|
|
}
|