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>
76 lines
2.5 KiB
Go
76 lines
2.5 KiB
Go
package multi_test
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/disk"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/parsers"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/progress"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/contextargs"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
|
"github.com/projectdiscovery/ratelimit"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var executerOpts protocols.ExecutorOptions
|
|
|
|
func setup() {
|
|
options := testutils.DefaultOptions
|
|
testutils.Init(options)
|
|
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
|
|
|
|
executerOpts = protocols.ExecutorOptions{
|
|
Output: testutils.NewMockOutputWriter(),
|
|
Options: options,
|
|
Progress: progressImpl,
|
|
ProjectFile: nil,
|
|
IssuesClient: nil,
|
|
Browser: nil,
|
|
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
|
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
|
}
|
|
workflowLoader, err := parsers.NewLoader(&executerOpts)
|
|
if err != nil {
|
|
log.Fatalf("Could not create workflow loader: %s\n", err)
|
|
}
|
|
executerOpts.WorkflowLoader = workflowLoader
|
|
}
|
|
|
|
func TestMultiProtoWithDynamicExtractor(t *testing.T) {
|
|
setup()
|
|
Template, err := templates.Parse("testcases/multiprotodynamic.yaml", nil, executerOpts)
|
|
require.Nil(t, err, "could not parse template")
|
|
|
|
require.Equal(t, 2, len(Template.MultiProtoRequest.Queue))
|
|
|
|
err = Template.MultiProtoRequest.Compile(&executerOpts)
|
|
require.Nil(t, err, "could not compile template")
|
|
|
|
gotresults, err := Template.Executer.Execute(contextargs.NewWithInput("blog.projectdiscovery.io"))
|
|
require.Nil(t, err, "could not execute template")
|
|
require.True(t, gotresults)
|
|
}
|
|
|
|
func TestMultiProtoWithProtoPrefix(t *testing.T) {
|
|
setup()
|
|
Template, err := templates.Parse("testcases/multiprotowithprefix.yaml", nil, executerOpts)
|
|
require.Nil(t, err, "could not parse template")
|
|
|
|
require.Equal(t, 3, len(Template.MultiProtoRequest.Queue))
|
|
|
|
err = Template.MultiProtoRequest.Compile(&executerOpts)
|
|
require.Nil(t, err, "could not compile template")
|
|
|
|
require.True(t, len(Template.MultiProtoRequest.GetCompiledOperators()) > 0, "could not compile operators")
|
|
|
|
gotresults, err := Template.Executer.Execute(contextargs.NewWithInput("blog.projectdiscovery.io"))
|
|
require.Nil(t, err, "could not execute template")
|
|
require.True(t, gotresults)
|
|
}
|