mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 08:25:26 +00:00
* multi proto request genesis * adds template context dynamic vars * feat: proto level resp variables * remove proto prefix hacky logic * implement template ctx args * remove old var name logic * improve AddTemplateVars func * add multi proto comments+docs * vardump with sorted keys * fix race condition in ctx args * default initialize ctx args * use generic map * index variables with multiple values * fix nil cookies * use synclock map * fix build failure * fix lint error * resolve merge conflicts * multi proto: add unit+ integration tests * fix unit tests * Issue 3339 headless fuzz (#3790) * Basic headless fuzzing * Remove debug statements * Add integration tests * Update template * Fix recognize payload value in matcher * Update tempalte * use req.SetURL() --------- Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io> * Auto Generate Syntax Docs + JSONSchema [Fri Jun 9 00:23:32 UTC 2023] 🤖 * Add headless header and status matchers (#3794) * add headless header and status matchers * rename headers as header * add integration test for header+status * fix typo --------- Co-authored-by: Shubham Rasal <shubham@projectdiscovery.io> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Dogan Can Bakir <65292895+dogancanbakir@users.noreply.github.com>
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package fuzz
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestRuleMatchKeyOrValue(t *testing.T) {
|
|
rule := &Rule{}
|
|
err := rule.Compile(nil, nil)
|
|
require.NoError(t, err, "could not compile rule")
|
|
|
|
result := rule.matchKeyOrValue("url", "")
|
|
require.True(t, result, "could not get correct result")
|
|
|
|
t.Run("key", func(t *testing.T) {
|
|
rule := &Rule{Keys: []string{"url"}}
|
|
err := rule.Compile(nil, nil)
|
|
require.NoError(t, err, "could not compile rule")
|
|
|
|
result := rule.matchKeyOrValue("url", "")
|
|
require.True(t, result, "could not get correct result")
|
|
result = rule.matchKeyOrValue("test", "")
|
|
require.False(t, result, "could not get correct result")
|
|
})
|
|
t.Run("value", func(t *testing.T) {
|
|
rule := &Rule{ValuesRegex: []string{`https?:\/\/?([-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b)*(\/[\/\d\w\.-]*)*(?:[\?])*(.+)*`}}
|
|
err := rule.Compile(nil, nil)
|
|
require.NoError(t, err, "could not compile rule")
|
|
|
|
result := rule.matchKeyOrValue("", "http://localhost:80")
|
|
require.True(t, result, "could not get correct result")
|
|
result = rule.matchKeyOrValue("test", "random")
|
|
require.False(t, result, "could not get correct result")
|
|
})
|
|
}
|