testutils

package
v3.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ExtraDebugArgs = []string{}
	ExtraEnvVars   = []string{
		"DISABLE_CLOUD_UPLOAD_WRN=true",
		"DISABLE_CLOUD_UPLOAD=true",
	}
)

ExtraArgs

View Source
var DefaultOptions = &types.Options{
	Metrics:                    false,
	Debug:                      false,
	DebugRequests:              false,
	DebugResponse:              false,
	Silent:                     false,
	Verbose:                    false,
	NoColor:                    true,
	UpdateTemplates:            false,
	JSONL:                      false,
	OmitRawRequests:            false,
	EnableProgressBar:          false,
	TemplateList:               false,
	Stdin:                      false,
	StopAtFirstMatch:           false,
	NoMeta:                     false,
	Project:                    false,
	MetricsPort:                0,
	BulkSize:                   25,
	TemplateThreads:            10,
	Timeout:                    5,
	Retries:                    1,
	RateLimit:                  150,
	RateLimitDuration:          time.Second,
	ProbeConcurrency:           50,
	ProjectPath:                "",
	Severities:                 severity.Severities{},
	Targets:                    []string{},
	TargetsFilePath:            "",
	Output:                     "",
	Proxy:                      []string{},
	TraceLogFile:               "",
	Templates:                  []string{},
	ExcludedTemplates:          []string{},
	CustomHeaders:              []string{},
	InteractshURL:              "https://oast.fun",
	InteractionsCacheSize:      5000,
	InteractionsEviction:       60,
	InteractionsCoolDownPeriod: 5,
	InteractionsPollDuration:   5,
	GitHubTemplateRepo:         []string{},
	GitHubToken:                "",
}

DefaultOptions is the default options structure for nuclei during mocking.

Functions

func Init

func Init(options *types.Options)

Init initializes the protocols and their configurations

func NewMockExecuterOptions

func NewMockExecuterOptions(options *types.Options, info *TemplateInfo) *protocols.ExecutorOptions

NewMockExecuterOptions creates a new mock executeroptions struct

func NewWebsocketServer

func NewWebsocketServer(path string, handler func(conn net.Conn), originValidate func(origin string) bool, port ...int) *httptest.Server

NewWebsocketServer creates a new websocket server from a handler

func RunNucleiAndGetResults

func RunNucleiAndGetResults(isTemplate bool, template, url string, debug bool, extra ...string) ([]string, error)

func RunNucleiArgsAndGetErrors

func RunNucleiArgsAndGetErrors(debug bool, env []string, extra ...string) ([]string, error)

RunNucleiArgsAndGetErrors returns a list of errors in nuclei output (ERR,WRN,FTL)

func RunNucleiArgsWithEnvAndGetResults

func RunNucleiArgsWithEnvAndGetResults(debug bool, env []string, extra ...string) ([]string, error)

RunNucleiArgsWithEnvAndGetResults returns a list of results in nuclei output (ERR,WRN,FTL)

func RunNucleiBareArgsAndGetResults

func RunNucleiBareArgsAndGetResults(debug bool, env []string, extra ...string) ([]string, error)

func RunNucleiBinaryAndGetCombinedOutput

func RunNucleiBinaryAndGetCombinedOutput(debug bool, args []string) (string, error)

func RunNucleiBinaryAndGetLoadedTemplates

func RunNucleiBinaryAndGetLoadedTemplates(nucleiBinary string, debug bool, args []string) (string, error)

RunNucleiBinaryAndGetLoadedTemplates returns a list of results for a template

func RunNucleiTemplateAndGetResults

func RunNucleiTemplateAndGetResults(template, url string, debug bool, extra ...string) ([]string, error)

RunNucleiTemplateAndGetResults returns a list of results for a template

func RunNucleiWithArgsAndGetResults

func RunNucleiWithArgsAndGetResults(debug bool, args ...string) ([]string, error)

RunNucleiArgsAndGetResults returns result,and runtime errors

func RunNucleiWorkflowAndGetResults

func RunNucleiWorkflowAndGetResults(template, url string, debug bool, extra ...string) ([]string, error)

RunNucleiWorkflowAndGetResults returns a list of results for a workflow

Types

type MockOutputWriter

type MockOutputWriter struct {
	RequestCallback func(templateID, url, requestType string, err error)
	FailureCallback func(result *output.InternalEvent)
	WriteCallback   func(o *output.ResultEvent)
	// contains filtered or unexported fields
}

MockOutputWriter is a mocked output writer.

func NewMockOutputWriter

func NewMockOutputWriter(omomitTemplate bool) *MockOutputWriter

NewMockOutputWriter creates a new mock output writer

func (*MockOutputWriter) Close

func (m *MockOutputWriter) Close()

Close closes the output writer interface

func (*MockOutputWriter) Colorizer

func (m *MockOutputWriter) Colorizer() aurora.Aurora

Colorizer returns the colorizer instance for writer

func (*MockOutputWriter) Request

func (m *MockOutputWriter) Request(templateID, url, requestType string, err error)

Request writes a log the requests trace log

func (*MockOutputWriter) Write

func (m *MockOutputWriter) Write(result *output.ResultEvent) error

Write writes the event to file and/or screen.

func (*MockOutputWriter) WriteFailure

func (m *MockOutputWriter) WriteFailure(wrappedEvent *output.InternalWrappedEvent) error

WriteFailure writes the event to file and/or screen.

func (*MockOutputWriter) WriteStoreDebugData

func (m *MockOutputWriter) WriteStoreDebugData(host, templateID, eventType string, data string)

type MockProgressClient

type MockProgressClient struct{}

func (*MockProgressClient) AddToTotal

func (m *MockProgressClient) AddToTotal(delta int64)

AddToTotal adds a value to the total request count

func (*MockProgressClient) IncrementErrorsBy

func (m *MockProgressClient) IncrementErrorsBy(count int64)

IncrementErrorsBy increments the error counter by count.

func (*MockProgressClient) IncrementFailedRequestsBy

func (m *MockProgressClient) IncrementFailedRequestsBy(count int64)

IncrementFailedRequestsBy increments the number of requests counter by count along with errors.

func (*MockProgressClient) IncrementMatched

func (m *MockProgressClient) IncrementMatched()

IncrementMatched increments the matched counter by 1.

func (*MockProgressClient) IncrementRequests

func (m *MockProgressClient) IncrementRequests()

IncrementRequests increments the requests counter by 1.

func (*MockProgressClient) Init

func (m *MockProgressClient) Init(hostCount int64, rulesCount int, requestCount int64)

Init inits the progress bar with initial details for scan

func (*MockProgressClient) SetRequests

func (m *MockProgressClient) SetRequests(count uint64)

SetRequests sets the counter by incrementing it with a delta

func (*MockProgressClient) Stop

func (m *MockProgressClient) Stop()

Stop stops the progress recorder.

type NoopWriter

type NoopWriter struct{}

NoopWriter is a NooP gologger writer.

func (*NoopWriter) Write

func (n *NoopWriter) Write(data []byte, level levels.Level)

Write writes the data to an output writer.

type TCPServer

type TCPServer struct {
	URL string
	// contains filtered or unexported fields
}

TCPServer creates a new tcp server that returns a response

func NewTCPServer

func NewTCPServer(tlsConfig *tls.Config, port int, handler func(conn net.Conn)) *TCPServer

NewTCPServer creates a new TCP server from a handler

func (*TCPServer) Close

func (s *TCPServer) Close()

Close closes the TCP server

type TemplateInfo

type TemplateInfo struct {
	ID   string
	Info model.Info
	Path string
}

TemplateInfo contains info for a mock executed template.

type TestCase

type TestCase interface {
	// Execute executes a test case and returns any errors if occurred
	Execute(filePath string) error
}

TestCase is a single integration test case

Directories

Path Synopsis
This package provides a mock server for testing fuzzing templates
This package provides a mock server for testing fuzzing templates

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL