"Executer" to "Executor" (#3760)

* Fix spelling of "executer" to "executor"

* minor change: use defer file.Close()

---------

Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
dev
Keith Chason 2023-05-31 16:58:10 -04:00 committed by GitHub
parent 7d5fa300ee
commit 4d6080f3bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 125 additions and 127 deletions

View File

@ -109,8 +109,8 @@ func process() error {
defer os.RemoveAll(tempDir)
client := nvd.NewClientV2()
catalog := disk.NewCatalog(filepath.Dir(*input))
paths, err := catalog.GetTemplatePath(*input)
templateCatalog := disk.NewCatalog(filepath.Dir(*input))
paths, err := templateCatalog.GetTemplatePath(*input)
if err != nil {
return err
}
@ -121,7 +121,7 @@ func process() error {
}
dataString := string(data)
// try to fill max-requests
dataString, err = parseAndAddMaxRequests(catalog, path, dataString)
dataString, err = parseAndAddMaxRequests(templateCatalog, path, dataString)
if err != nil {
gologger.Error().Msgf("Could not compile max request %s: %s\n", path, err)
}
@ -291,7 +291,7 @@ func getCVEData(client *nvd.ClientV2, filePath, data string) {
changed = true
node := config.Nodes[0]
for _, match := range node.CpeMatch {
cpeSet[extractVersionlessCpe((match.Criteria))] = true
cpeSet[extractVersionlessCpe(match.Criteria)] = true
}
}
}
@ -538,7 +538,7 @@ func suggestTagsBasedOnReference(references, currentTags []string) []string {
return newTags
}
// Cloning struct from nuclei as we don't want any validation
// InfoBlock Cloning struct from nuclei as we don't want any validation
type InfoBlock struct {
Info TemplateInfo `yaml:"info"`
}
@ -618,15 +618,15 @@ func parseAndAddMaxRequests(catalog catalog.Catalog, path, data string) (string,
// parseTemplate parses a template and returns the template object
func parseTemplate(catalog catalog.Catalog, templatePath string) (*templates.Template, error) {
executerOpts := protocols.ExecuterOptions{
executorOpts := protocols.ExecutorOptions{
Catalog: catalog,
Options: defaultOpts,
}
reader, err := executerOpts.Catalog.OpenFile(templatePath)
reader, err := executorOpts.Catalog.OpenFile(templatePath)
if err != nil {
return nil, err
}
template, err := templates.ParseTemplateFromReader(reader, nil, executerOpts)
template, err := templates.ParseTemplateFromReader(reader, nil, executorOpts)
if err != nil {
return nil, err
}
@ -638,7 +638,7 @@ func getInfoStartEnd(data string) (int, int) {
info := strings.Index(data, "info:")
var indices []int
for _, re := range allTagsRegex {
// find the first occurance of the label
// find the first occurrence of the label
match := re.FindStringIndex(data)
if match != nil {
indices = append(indices, match[0])

View File

@ -99,7 +99,7 @@ func executeNucleiAsCode(templatePath, templateURL string) ([]string, error) {
catalog := disk.NewCatalog(path.Join(home, "nuclei-templates"))
ratelimiter := ratelimit.New(context.Background(), 150, time.Second)
defer ratelimiter.Stop()
executerOpts := protocols.ExecuterOptions{
executerOpts := protocols.ExecutorOptions{
Output: outputWriter,
Options: defaultOpts,
Progress: mockProgress,

View File

@ -59,7 +59,7 @@ func main() {
home, _ := os.UserHomeDir()
catalog := disk.NewCatalog(path.Join(home, "nuclei-templates"))
executerOpts := protocols.ExecuterOptions{
executerOpts := protocols.ExecutorOptions{
Output: outputWriter,
Options: defaultOpts,
Progress: mockProgress,

View File

@ -27,7 +27,7 @@ import (
)
// runStandardEnumeration runs standard enumeration
func (r *Runner) runStandardEnumeration(executerOpts protocols.ExecuterOptions, store *loader.Store, engine *core.Engine) (*atomic.Bool, error) {
func (r *Runner) runStandardEnumeration(executerOpts protocols.ExecutorOptions, store *loader.Store, engine *core.Engine) (*atomic.Bool, error) {
if r.options.AutomaticScan {
return r.executeSmartWorkflowInput(executerOpts, store, engine)
}

View File

@ -46,7 +46,7 @@ import (
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/headless/engine"
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/httpclientpool"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting"
json_exporter "github.com/projectdiscovery/nuclei/v2/pkg/reporting/exporters/jsonexporter"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/exporters/jsonexporter"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/exporters/jsonl"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/exporters/markdown"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/exporters/sarif"
@ -70,7 +70,7 @@ type Runner struct {
issuesClient reporting.Client
hmapInputProvider *hybrid.Input
browser *engine.Browser
ratelimiter *ratelimit.Limiter
rateLimiter *ratelimit.Limiter
hostErrors hosterrorscache.CacheInterface
resumeCfg *types.ResumeCfg
pprofServer *http.Server
@ -80,7 +80,7 @@ type Runner struct {
const pprofServerAddress = "127.0.0.1:8086"
// New creates a new client for running enumeration process.
// New creates a new client for running the enumeration process.
func New(options *types.Options) (*Runner, error) {
runner := &Runner{
options: options,
@ -109,8 +109,8 @@ func New(options *types.Options) (*Runner, error) {
gologger.Error().Label("custom-templates").Msgf("Failed to create custom templates manager: %s\n", err)
}
// Check for template updates and update if available
// if custom templates manager is not nil, we will install custom templates if there is fresh installation
// Check for template updates and update if available.
// If the custom templates manager is not nil, we will install custom templates if there is a fresh installation
tm := &installer.TemplateManager{CustomTemplates: ctm}
if err := tm.FreshInstallIfNotExists(); err != nil {
gologger.Warning().Msgf("failed to install nuclei templates: %s\n", err)
@ -278,7 +278,7 @@ func New(options *types.Options) (*Runner, error) {
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(file), &resumeCfg)
err = json.Unmarshal(file, &resumeCfg)
if err != nil {
return nil, err
}
@ -313,11 +313,11 @@ func New(options *types.Options) (*Runner, error) {
}
if options.RateLimitMinute > 0 {
runner.ratelimiter = ratelimit.New(context.Background(), uint(options.RateLimitMinute), time.Minute)
runner.rateLimiter = ratelimit.New(context.Background(), uint(options.RateLimitMinute), time.Minute)
} else if options.RateLimit > 0 {
runner.ratelimiter = ratelimit.New(context.Background(), uint(options.RateLimit), time.Second)
runner.rateLimiter = ratelimit.New(context.Background(), uint(options.RateLimit), time.Second)
} else {
runner.ratelimiter = ratelimit.NewUnlimited(context.Background())
runner.rateLimiter = ratelimit.NewUnlimited(context.Background())
}
return runner, nil
}
@ -329,14 +329,12 @@ func createReportingOptions(options *types.Options) (*reporting.Options, error)
if err != nil {
return nil, errors.Wrap(err, "could not open reporting config file")
}
defer file.Close()
reportingOptions = &reporting.Options{}
if err := yaml.DecodeAndValidate(file, reportingOptions); err != nil {
file.Close()
return nil, errors.Wrap(err, "could not parse reporting config file")
}
file.Close()
Walk(reportingOptions, expandEndVars)
}
if options.MarkdownExportDirectory != "" {
@ -357,10 +355,10 @@ func createReportingOptions(options *types.Options) (*reporting.Options, error)
}
if options.JSONExport != "" {
if reportingOptions != nil {
reportingOptions.JSONExporter = &json_exporter.Options{File: options.JSONExport}
reportingOptions.JSONExporter = &jsonexporter.Options{File: options.JSONExport}
} else {
reportingOptions = &reporting.Options{}
reportingOptions.JSONExporter = &json_exporter.Options{File: options.JSONExport}
reportingOptions.JSONExporter = &jsonexporter.Options{File: options.JSONExport}
}
}
if options.JSONLExport != "" {
@ -388,8 +386,8 @@ func (r *Runner) Close() {
if r.pprofServer != nil {
_ = r.pprofServer.Shutdown(context.Background())
}
if r.ratelimiter != nil {
r.ratelimiter.Stop()
if r.rateLimiter != nil {
r.rateLimiter.Stop()
}
}
@ -414,15 +412,15 @@ func (r *Runner) RunEnumeration() error {
r.options.ExcludedTemplates = append(r.options.ExcludedTemplates, ignoreFile.Files...)
}
// Create the executer options which will be used throughout the execution
// Create the executor options which will be used throughout the execution
// stage by the nuclei engine modules.
executerOpts := protocols.ExecuterOptions{
executorOpts := protocols.ExecutorOptions{
Output: r.output,
Options: r.options,
Progress: r.progress,
Catalog: r.catalog,
IssuesClient: r.issuesClient,
RateLimiter: r.ratelimiter,
RateLimiter: r.rateLimiter,
Interactsh: r.interactsh,
ProjectFile: r.projectFile,
Browser: r.browser,
@ -436,19 +434,19 @@ func (r *Runner) RunEnumeration() error {
cache := hosterrorscache.New(r.options.MaxHostError, hosterrorscache.DefaultMaxHostsCount, r.options.TrackError)
cache.SetVerbose(r.options.Verbose)
r.hostErrors = cache
executerOpts.HostErrorsCache = cache
executorOpts.HostErrorsCache = cache
}
engine := core.New(r.options)
engine.SetExecuterOptions(executerOpts)
executorEngine := core.New(r.options)
executorEngine.SetExecuterOptions(executorOpts)
workflowLoader, err := parsers.NewLoader(&executerOpts)
workflowLoader, err := parsers.NewLoader(&executorOpts)
if err != nil {
return errors.Wrap(err, "Could not create loader.")
}
executerOpts.WorkflowLoader = workflowLoader
executorOpts.WorkflowLoader = workflowLoader
store, err := loader.New(loader.NewConfig(r.options, r.catalog, executerOpts))
store, err := loader.New(loader.NewConfig(r.options, r.catalog, executorOpts))
if err != nil {
return errors.Wrap(err, "could not load templates from config")
}
@ -512,14 +510,14 @@ func (r *Runner) RunEnumeration() error {
r.displayExecutionInfo(store)
// If not explicitly disabled, check if http based protocols
// are used and if inputs are non-http to pre-perform probing
// are used, and if inputs are non-http to pre-perform probing
// of urls and storing them for execution.
if !r.options.DisableHTTPProbe && loader.IsHTTPBasedProtocolUsed(store) && r.isInputNonHTTP() {
inputHelpers, err := r.initializeTemplatesHTTPInput()
if err != nil {
return errors.Wrap(err, "could not probe http input")
}
executerOpts.InputHelper.InputsHTTP = inputHelpers
executorOpts.InputHelper.InputsHTTP = inputHelpers
}
enumeration := false
@ -570,7 +568,7 @@ func (r *Runner) RunEnumeration() error {
enumeration = true
}
} else {
results, err = r.runStandardEnumeration(executerOpts, store, engine)
results, err = r.runStandardEnumeration(executorOpts, store, executorEngine)
enumeration = true
}
@ -586,8 +584,8 @@ func (r *Runner) RunEnumeration() error {
}
r.progress.Stop()
if executerOpts.InputHelper != nil {
_ = executerOpts.InputHelper.Close()
if executorOpts.InputHelper != nil {
_ = executorOpts.InputHelper.Close()
}
if r.issuesClient != nil {
r.issuesClient.Close()
@ -599,7 +597,7 @@ func (r *Runner) RunEnumeration() error {
if r.browser != nil {
r.browser.Close()
}
// check if passive scan was requested but no target was provided
// check if a passive scan was requested but no target was provided
if r.options.OfflineHTTP && len(r.options.Targets) == 0 && r.options.TargetsFilePath == "" {
return errors.Wrap(err, "missing required input (http response) to run passive templates")
}
@ -619,11 +617,11 @@ func (r *Runner) isInputNonHTTP() bool {
return nonURLInput
}
func (r *Runner) executeSmartWorkflowInput(executerOpts protocols.ExecuterOptions, store *loader.Store, engine *core.Engine) (*atomic.Bool, error) {
func (r *Runner) executeSmartWorkflowInput(executorOpts protocols.ExecutorOptions, store *loader.Store, engine *core.Engine) (*atomic.Bool, error) {
r.progress.Init(r.hmapInputProvider.Count(), 0, 0)
service, err := automaticscan.New(automaticscan.Options{
ExecuterOpts: executerOpts,
ExecuterOpts: executorOpts,
Store: store,
Engine: engine,
Target: r.hmapInputProvider,
@ -676,7 +674,7 @@ func (r *Runner) executeTemplatesInput(store *loader.Store, engine *core.Engine)
workflowCount := len(store.Workflows())
templateCount := originalTemplatesCount + workflowCount
// 0 matches means no templates were found in directory
// 0 matches means no templates were found in the directory
if templateCount == 0 {
return &atomic.Bool{}, errors.New("no valid templates were found")
}
@ -726,7 +724,7 @@ type WalkFunc func(reflect.Value, reflect.StructField)
// Walk traverses a struct and executes a callback function on each value in the struct.
// The interface{} passed to the function should be a pointer to a struct or a struct.
// WalkFunc is the callback function used for each value in the struct. It is passed the
// reflect.Value and reflect.Type of the value in the struct.
// reflect.Value and reflect.Type properties of the value in the struct.
func Walk(s interface{}, callback WalkFunc) {
structValue := reflect.ValueOf(s)
if structValue.Kind() == reflect.Ptr {

View File

@ -42,7 +42,7 @@ type Config struct {
IncludeConditions []string
Catalog catalog.Catalog
ExecutorOptions protocols.ExecuterOptions
ExecutorOptions protocols.ExecutorOptions
}
// Store is a storage for loaded nuclei templates
@ -64,7 +64,7 @@ type Store struct {
}
// NewConfig returns a new loader config
func NewConfig(options *types.Options, catalog catalog.Catalog, executerOpts protocols.ExecuterOptions) *Config {
func NewConfig(options *types.Options, catalog catalog.Catalog, executerOpts protocols.ExecutorOptions) *Config {
loaderConfig := Config{
Templates: options.Templates,
Workflows: options.Workflows,

View File

@ -18,7 +18,7 @@ import (
type Engine struct {
workPool *WorkPool
options *types.Options
executerOpts protocols.ExecuterOptions
executerOpts protocols.ExecutorOptions
Callback func(*output.ResultEvent) // Executed on results
}
@ -58,12 +58,12 @@ func (e *Engine) GetWorkPool() *WorkPool {
// SetExecuterOptions sets the executer options for the engine. This is required
// before using the engine to perform any execution.
func (e *Engine) SetExecuterOptions(options protocols.ExecuterOptions) {
func (e *Engine) SetExecuterOptions(options protocols.ExecutorOptions) {
e.executerOpts = options
}
// ExecuterOptions returns protocols.ExecuterOptions for nuclei engine.
func (e *Engine) ExecuterOptions() protocols.ExecuterOptions {
// ExecuterOptions returns protocols.ExecutorOptions for nuclei engine.
func (e *Engine) ExecuterOptions() protocols.ExecutorOptions {
return e.executerOpts
}

View File

@ -17,9 +17,9 @@ import (
func TestWorkflowsSimple(t *testing.T) {
progressBar, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
workflow := &workflows.Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
workflow := &workflows.Workflow{Options: &protocols.ExecutorOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
Executer: &mockExecuter{result: true}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}},
}}
@ -32,16 +32,16 @@ func TestWorkflowsSimpleMultiple(t *testing.T) {
progressBar, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
var firstInput, secondInput string
workflow := &workflows.Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
workflow := &workflows.Workflow{Options: &protocols.ExecutorOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
firstInput = input.Input
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}},
{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
secondInput = input.Input
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}},
}}
@ -57,17 +57,17 @@ func TestWorkflowsSubtemplates(t *testing.T) {
progressBar, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
var firstInput, secondInput string
workflow := &workflows.Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
workflow := &workflows.Workflow{Options: &protocols.ExecutorOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
firstInput = input.Input
}, outputs: []*output.InternalWrappedEvent{
{OperatorsResult: &operators.Result{}, Results: []*output.ResultEvent{{}}},
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}, Subtemplates: []*workflows.WorkflowTemplate{{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
secondInput = input.Input
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}}}},
}}
@ -83,15 +83,15 @@ func TestWorkflowsSubtemplatesNoMatch(t *testing.T) {
progressBar, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
var firstInput, secondInput string
workflow := &workflows.Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
workflow := &workflows.Workflow{Options: &protocols.ExecutorOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: false, executeHook: func(input *contextargs.MetaInput) {
firstInput = input.Input
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}, Subtemplates: []*workflows.WorkflowTemplate{{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
secondInput = input.Input
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}}}},
}}
@ -107,7 +107,7 @@ func TestWorkflowsSubtemplatesWithMatcher(t *testing.T) {
progressBar, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
var firstInput, secondInput string
workflow := &workflows.Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
workflow := &workflows.Workflow{Options: &protocols.ExecutorOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
firstInput = input.Input
@ -116,11 +116,11 @@ func TestWorkflowsSubtemplatesWithMatcher(t *testing.T) {
Matches: map[string][]string{"tomcat": {}},
Extracts: map[string][]string{},
}},
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}, Matchers: []*workflows.Matcher{{Name: stringslice.StringSlice{Value: "tomcat"}, Subtemplates: []*workflows.WorkflowTemplate{{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
secondInput = input.Input
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}}}}}},
}}
@ -136,7 +136,7 @@ func TestWorkflowsSubtemplatesWithMatcherNoMatch(t *testing.T) {
progressBar, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
var firstInput, secondInput string
workflow := &workflows.Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
workflow := &workflows.Workflow{Options: &protocols.ExecutorOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*workflows.WorkflowTemplate{
{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
firstInput = input.Input
@ -145,11 +145,11 @@ func TestWorkflowsSubtemplatesWithMatcherNoMatch(t *testing.T) {
Matches: map[string][]string{"tomcat": {}},
Extracts: map[string][]string{},
}},
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}, Matchers: []*workflows.Matcher{{Name: stringslice.StringSlice{Value: "apache"}, Subtemplates: []*workflows.WorkflowTemplate{{Executers: []*workflows.ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input *contextargs.MetaInput) {
secondInput = input.Input
}}, Options: &protocols.ExecuterOptions{Progress: progressBar}},
}}, Options: &protocols.ExecutorOptions{Progress: progressBar}},
}}}}}},
}}

View File

@ -11,11 +11,11 @@ import (
type workflowLoader struct {
pathFilter *filter.PathFilter
tagFilter *filter.TagFilter
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
}
// NewLoader returns a new workflow loader structure
func NewLoader(options *protocols.ExecuterOptions) (model.WorkflowLoader, error) {
func NewLoader(options *protocols.ExecutorOptions) (model.WorkflowLoader, error) {
tagFilter, err := filter.New(&filter.Config{
Authors: options.Options.Authors,
Tags: options.Options.Tags,

View File

@ -26,7 +26,7 @@ import (
// Service is a service for automatic scan execution
type Service struct {
opts protocols.ExecuterOptions
opts protocols.ExecutorOptions
store *loader.Store
engine *core.Engine
target core.InputProvider
@ -41,7 +41,7 @@ type Service struct {
// Options contains configuration options for automatic scan service
type Options struct {
ExecuterOpts protocols.ExecuterOptions
ExecuterOpts protocols.ExecutorOptions
Store *loader.Store
Engine *core.Engine
Target core.InputProvider

View File

@ -18,13 +18,13 @@ import (
// Executer executes a group of requests for a protocol
type Executer struct {
requests []protocols.Request
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
}
var _ protocols.Executer = &Executer{}
// NewExecuter creates a new request executer for list of requests
func NewExecuter(requests []protocols.Request, options *protocols.ExecuterOptions) *Executer {
func NewExecuter(requests []protocols.Request, options *protocols.ExecutorOptions) *Executer {
return &Executer{requests: requests, options: options}
}

View File

@ -79,7 +79,7 @@ type Request struct {
CompiledOperators *operators.Operators `yaml:"-"`
dnsClient *retryabledns.Client
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
// cache any variables that may be needed for operation.
class uint16
@ -122,12 +122,12 @@ func (request *Request) GetID() string {
}
// Options returns executer options for http request
func (r *Request) Options() *protocols.ExecuterOptions {
func (r *Request) Options() *protocols.ExecutorOptions {
return r.options
}
// Compile compiles the protocol request for further execution.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
if request.Retries == 0 {
request.Retries = 3
}
@ -180,7 +180,7 @@ func (request *Request) Compile(options *protocols.ExecuterOptions) error {
return nil
}
func (request *Request) getDnsClient(options *protocols.ExecuterOptions, metadata map[string]interface{}) (*retryabledns.Client, error) {
func (request *Request) getDnsClient(options *protocols.ExecutorOptions, metadata map[string]interface{}) (*retryabledns.Client, error) {
dnsClientOptions := &dnsclientpool.Configuration{
Retries: request.Retries,
}

View File

@ -184,7 +184,7 @@ func (request *Request) parseDNSInput(host string) (string, error) {
return host, nil
}
func dumpResponse(event *output.InternalWrappedEvent, request *Request, requestOptions *protocols.ExecuterOptions, response, domain string) {
func dumpResponse(event *output.InternalWrappedEvent, request *Request, requestOptions *protocols.ExecutorOptions, response, domain string) {
cliOptions := request.options.Options
if cliOptions.Debug || cliOptions.DebugResponse || cliOptions.StoreResponse {
hexDump := false
@ -203,7 +203,7 @@ func dumpResponse(event *output.InternalWrappedEvent, request *Request, requestO
}
}
func dumpTraceData(event *output.InternalWrappedEvent, requestOptions *protocols.ExecuterOptions, traceData, domain string) {
func dumpTraceData(event *output.InternalWrappedEvent, requestOptions *protocols.ExecutorOptions, traceData, domain string) {
cliOptions := requestOptions.Options
if cliOptions.Debug || cliOptions.DebugResponse {
hexDump := false

View File

@ -60,7 +60,7 @@ type Request struct {
CompiledOperators *operators.Operators `yaml:"-" json:"-"`
// cache any variables that may be needed for operation.
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
mimeTypesChecks []string
extensions map[string]struct{}
denyList map[string]struct{}
@ -98,7 +98,7 @@ func (request *Request) GetID() string {
}
// Compile compiles the protocol request for further execution.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
// if there are no matchers/extractors, we trigger an error as no operation would be performed on the template
if request.Operators.IsEmpty() {
return errors.New("empty operators")

View File

@ -323,7 +323,7 @@ func (request *Request) buildEvent(input, filePath string, fileMatches []FileMat
return event
}
func dumpResponse(event *output.InternalWrappedEvent, requestOptions *protocols.ExecuterOptions, filematches []FileMatch, filePath string) {
func dumpResponse(event *output.InternalWrappedEvent, requestOptions *protocols.ExecutorOptions, filematches []FileMatch, filePath string) {
cliOptions := requestOptions.Options
if cliOptions.Debug || cliOptions.DebugResponse {
for _, fileMatch := range filematches {

View File

@ -52,7 +52,7 @@ type Request struct {
CompiledOperators *operators.Operators `yaml:"-" json:"-"`
// cache any variables that may be needed for operation.
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
generator *generators.PayloadGenerator
}
@ -82,7 +82,7 @@ func (request *Request) GetID() string {
}
// Compile compiles the protocol request for further execution.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
// TODO: logic similar to network + http => probably can be refactored
// Resolve payload paths from vars if they exists
for name, payload := range options.Options.Vars.AsMap() {

View File

@ -159,7 +159,7 @@ func (request *Request) executeRequestWithPayloads(inputURL string, payloads map
return nil
}
func dumpResponse(event *output.InternalWrappedEvent, requestOptions *protocols.ExecuterOptions, responseBody string, input string) {
func dumpResponse(event *output.InternalWrappedEvent, requestOptions *protocols.ExecutorOptions, responseBody string, input string) {
cliOptions := requestOptions.Options
if cliOptions.Debug || cliOptions.DebugResponse {
highlightedResponse := responsehighlighter.Highlight(event.OperatorsResult, responseBody, cliOptions.NoColor, false)

View File

@ -87,7 +87,7 @@ func (rule *Rule) executeRuleValues(input *ExecuteRuleInput) error {
}
// Compile compiles a fuzzing rule and initializes it for operation
func (rule *Rule) Compile(generator *generators.PayloadGenerator, options *protocols.ExecuterOptions) error {
func (rule *Rule) Compile(generator *generators.PayloadGenerator, options *protocols.ExecutorOptions) error {
// If a payload generator is specified from base request, use it
// for payload values.
if generator != nil {

View File

@ -73,7 +73,7 @@ type Rule struct {
// []string{"{{ssrf}}", "{{interactsh-url}}", "example-value"}
Fuzz []string `yaml:"fuzz,omitempty" json:"fuzz,omitempty" jsonschema:"title=payloads of fuzz rule,description=Payloads to perform fuzzing substitutions with"`
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
generator *generators.PayloadGenerator
}

View File

@ -11,7 +11,7 @@ import (
func TestExecuteQueryPartRule(t *testing.T) {
parsed, _ := urlutil.Parse("http://localhost:8080/?url=localhost&mode=multiple&file=passwdfile")
options := &protocols.ExecuterOptions{
options := &protocols.ExecutorOptions{
Interactsh: &interactsh.Client{},
}
t.Run("single", func(t *testing.T) {

View File

@ -124,7 +124,7 @@ type Request struct {
CompiledOperators *operators.Operators `yaml:"-" json:"-"`
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
connConfiguration *httpclientpool.Configuration
totalRequests int
customHeaders map[string]string
@ -200,7 +200,7 @@ type Request struct {
}
// Options returns executer options for http request
func (r *Request) Options() *protocols.ExecuterOptions {
func (r *Request) Options() *protocols.ExecutorOptions {
return r.options
}
@ -236,7 +236,7 @@ func (request *Request) isRaw() bool {
}
// Compile compiles the protocol request for further execution.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
if err := request.validate(); err != nil {
return errors.Wrap(err, "validation error")
}

View File

@ -16,7 +16,7 @@ type requestGenerator struct {
currentPayloads map[string]interface{}
okCurrentPayload bool
request *Request
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
payloadIterator *generators.Iterator
interactshURLs []string
onceFlow map[string]struct{}

View File

@ -73,7 +73,7 @@ type Request struct {
generator *generators.PayloadGenerator
// cache any variables that may be needed for operation.
dialer *fastdialer.Dialer
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
}
// RequestPartDefinitions contains a mapping of request part definitions and their
@ -138,7 +138,7 @@ func (request *Request) GetID() string {
}
// Compile compiles the protocol request for further execution.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
var shouldUseTLS bool
var err error

View File

@ -9,7 +9,7 @@ import (
// Request is a offline http response processing request
type Request struct {
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
compiledOperators []*operators.Operators
}
@ -41,7 +41,7 @@ func (request *Request) GetID() string {
}
// Compile compiles the protocol request for further execution.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
for _, operator := range options.Operators {
if err := operator.Compile(); err != nil {
return errors.Wrap(err, "could not compile operators")

View File

@ -37,8 +37,8 @@ type Executer interface {
ExecuteWithResults(input *contextargs.Context, callback OutputEventCallback) error
}
// ExecuterOptions contains the configuration options for executer clients
type ExecuterOptions struct {
// ExecutorOptions contains the configuration options for executer clients
type ExecutorOptions struct {
// TemplateID is the ID of the template for the request
TemplateID string
// TemplatePath is the path of the template for the request
@ -88,7 +88,7 @@ type ExecuterOptions struct {
}
// Copy returns a copy of the executeroptions structure
func (e ExecuterOptions) Copy() ExecuterOptions {
func (e ExecutorOptions) Copy() ExecutorOptions {
copy := e
return copy
}
@ -96,7 +96,7 @@ func (e ExecuterOptions) Copy() ExecuterOptions {
// Request is an interface implemented any protocol based request generator.
type Request interface {
// Compile compiles the request generators preparing any requests possible.
Compile(options *ExecuterOptions) error
Compile(options *ExecutorOptions) error
// Requests returns the total number of requests the rule will perform
Requests() int
// GetID returns the ID for the request if any. IDs are used for multi-request

View File

@ -78,7 +78,7 @@ type Request struct {
// cache any variables that may be needed for operation.
dialer *fastdialer.Dialer
tlsx *tlsx.Service
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
}
// CanCluster returns true if the request can be clustered.
@ -93,7 +93,7 @@ func (request *Request) CanCluster(other *Request) bool {
}
// Compile compiles the request generators preparing any requests possible.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
request.options = options
client, err := networkclientpool.Get(options.Options, &networkclientpool.Configuration{})
@ -155,7 +155,7 @@ func (request *Request) Compile(options *protocols.ExecuterOptions) error {
}
// Options returns executer options for http request
func (r *Request) Options() *protocols.ExecuterOptions {
func (r *Request) Options() *protocols.ExecutorOptions {
return r.options
}

View File

@ -70,7 +70,7 @@ type Request struct {
// cache any variables that may be needed for operation.
dialer *fastdialer.Dialer
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
}
// Input is an input for the websocket protocol
@ -96,7 +96,7 @@ const (
)
// Compile compiles the request generators preparing any requests possible.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
request.options = options
client, err := networkclientpool.Get(options.Options, &networkclientpool.Configuration{})

View File

@ -46,12 +46,12 @@ type Request struct {
Server string `yaml:"server,omitempty" json:"server,omitempty" jsonschema:"title=server url to execute the WHOIS request on,description=Server contains the server url to execute the WHOIS request on"`
// cache any variables that may be needed for operation.
client *rdap.Client
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
parsedServerURL *url.URL
}
// Compile compiles the request generators preparing any requests possible.
func (request *Request) Compile(options *protocols.ExecuterOptions) error {
func (request *Request) Compile(options *protocols.ExecutorOptions) error {
var err error
if request.Server != "" {
request.parsedServerURL, err = url.Parse(request.Server)

View File

@ -113,7 +113,7 @@ func ClusterID(templates []*Template) string {
return cryptoutil.SHA256Sum(ids)
}
func ClusterTemplates(templatesList []*Template, options protocols.ExecuterOptions) ([]*Template, int) {
func ClusterTemplates(templatesList []*Template, options protocols.ExecutorOptions) ([]*Template, int) {
if options.Options.OfflineHTTP || options.Options.DisableClustering {
return templatesList, 0
}
@ -164,7 +164,7 @@ type ClusterExecuter struct {
requests protocols.Request
operators []*clusteredOperator
templateType types.ProtocolType
options *protocols.ExecuterOptions
options *protocols.ExecutorOptions
}
type clusteredOperator struct {
@ -177,7 +177,7 @@ type clusteredOperator struct {
var _ protocols.Executer = &ClusterExecuter{}
// NewClusterExecuter creates a new request executer for list of requests
func NewClusterExecuter(requests []*Template, options *protocols.ExecuterOptions) *ClusterExecuter {
func NewClusterExecuter(requests []*Template, options *protocols.ExecutorOptions) *ClusterExecuter {
executer := &ClusterExecuter{options: options}
if len(requests[0].RequestsDNS) == 1 {
executer.templateType = types.DNSProtocol

View File

@ -33,7 +33,7 @@ func init() {
// TODO make sure reading from the disk the template parsing happens once: see parsers.ParseTemplate vs templates.Parse
//
//nolint:gocritic // this cannot be passed by pointer
func Parse(filePath string, preprocessor Preprocessor, options protocols.ExecuterOptions) (*Template, error) {
func Parse(filePath string, preprocessor Preprocessor, options protocols.ExecutorOptions) (*Template, error) {
if !options.DoNotCache {
if value, err := parsedTemplatesCache.Has(filePath); value != nil {
return value.(*Template), err
@ -109,7 +109,7 @@ func (template *Template) Requests() int {
}
// compileProtocolRequests compiles all the protocol requests for the template
func (template *Template) compileProtocolRequests(options protocols.ExecuterOptions) error {
func (template *Template) compileProtocolRequests(options protocols.ExecutorOptions) error {
templateRequests := template.Requests()
if templateRequests == 0 {
@ -172,7 +172,7 @@ func (template *Template) convertRequestToProtocolsRequest(requests interface{})
// compileOfflineHTTPRequest iterates all requests if offline http mode is
// specified and collects all matchers for all the base request templates
// (those with URL {{BaseURL}} and it's slash variation.)
func (template *Template) compileOfflineHTTPRequest(options protocols.ExecuterOptions) error {
func (template *Template) compileOfflineHTTPRequest(options protocols.ExecutorOptions) error {
operatorsList := []*operators.Operators{}
mainLoop:
@ -200,7 +200,7 @@ mainLoop:
// ParseTemplateFromReader reads the template from reader
// returns the parsed template
func ParseTemplateFromReader(reader io.Reader, preprocessor Preprocessor, options protocols.ExecuterOptions) (*Template, error) {
func ParseTemplateFromReader(reader io.Reader, preprocessor Preprocessor, options protocols.ExecutorOptions) (*Template, error) {
template := &Template{}
data, err := io.ReadAll(reader)
if err != nil {

View File

@ -31,14 +31,14 @@ import (
"github.com/stretchr/testify/require"
)
var executerOpts protocols.ExecuterOptions
var executerOpts protocols.ExecutorOptions
func setup() {
options := testutils.DefaultOptions
testutils.Init(options)
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
executerOpts = protocols.ExecuterOptions{
executerOpts = protocols.ExecutorOptions{
Output: testutils.NewMockOutputWriter(),
Options: options,
Progress: progressImpl,
@ -162,7 +162,7 @@ func Test_ParseWorkflow(t *testing.T) {
},
Workflow: workflows.Workflow{
Workflows: []*workflows.WorkflowTemplate{{Template: "tests/match-1.yaml"}, {Template: "tests/match-1.yaml"}},
Options: &protocols.ExecuterOptions{},
Options: &protocols.ExecutorOptions{},
},
CompiledWorkflow: &workflows.Workflow{},
SelfContained: false,

View File

@ -10,7 +10,7 @@ import (
)
// compileWorkflow compiles the workflow for execution
func compileWorkflow(path string, preprocessor Preprocessor, options *protocols.ExecuterOptions, workflow *workflows.Workflow, loader model.WorkflowLoader) {
func compileWorkflow(path string, preprocessor Preprocessor, options *protocols.ExecutorOptions, workflow *workflows.Workflow, loader model.WorkflowLoader) {
for _, workflow := range workflow.Workflows {
if err := parseWorkflow(preprocessor, workflow, options, loader); err != nil {
gologger.Warning().Msgf("Could not parse workflow %s: %v\n", path, err)
@ -20,7 +20,7 @@ func compileWorkflow(path string, preprocessor Preprocessor, options *protocols.
}
// parseWorkflow parses and compiles all templates in a workflow recursively
func parseWorkflow(preprocessor Preprocessor, workflow *workflows.WorkflowTemplate, options *protocols.ExecuterOptions, loader model.WorkflowLoader) error {
func parseWorkflow(preprocessor Preprocessor, workflow *workflows.WorkflowTemplate, options *protocols.ExecutorOptions, loader model.WorkflowLoader) error {
shouldNotValidate := false
if workflow.Template == "" && workflow.Tags.IsEmpty() {
@ -55,7 +55,7 @@ func parseWorkflow(preprocessor Preprocessor, workflow *workflows.WorkflowTempla
}
// parseWorkflowTemplate parses a workflow template creating an executer
func parseWorkflowTemplate(workflow *workflows.WorkflowTemplate, preprocessor Preprocessor, options *protocols.ExecuterOptions, loader model.WorkflowLoader, noValidate bool) error {
func parseWorkflowTemplate(workflow *workflows.WorkflowTemplate, preprocessor Preprocessor, options *protocols.ExecutorOptions, loader model.WorkflowLoader, noValidate bool) error {
var paths []string
subTemplateTags := workflow.Tags

View File

@ -76,9 +76,9 @@ type TemplateInfo struct {
}
// NewMockExecuterOptions creates a new mock executeroptions struct
func NewMockExecuterOptions(options *types.Options, info *TemplateInfo) *protocols.ExecuterOptions {
func NewMockExecuterOptions(options *types.Options, info *TemplateInfo) *protocols.ExecutorOptions {
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, false, 0)
executerOpts := &protocols.ExecuterOptions{
executerOpts := &protocols.ExecutorOptions{
TemplateID: info.ID,
TemplateInfo: info.Info,
TemplatePath: info.Path,

View File

@ -15,7 +15,7 @@ type Workflow struct {
// Workflows is a list of workflows to execute for a template.
Workflows []*WorkflowTemplate `yaml:"workflows,omitempty" json:"workflows,omitempty" jsonschema:"title=list of workflows to execute,description=List of workflows to execute for template"`
Options *protocols.ExecuterOptions `yaml:"-" json:"-"`
Options *protocols.ExecutorOptions `yaml:"-" json:"-"`
}
// WorkflowTemplate is a template to be run as part of a workflow
@ -44,7 +44,7 @@ type WorkflowTemplate struct {
// ProtocolExecuterPair is a pair of protocol executer and its options
type ProtocolExecuterPair struct {
Executer protocols.Executer
Options *protocols.ExecuterOptions
Options *protocols.ExecutorOptions
TemplateType templateTypes.ProtocolType
}