contextargs

package
v3.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 18 Imported by: 6 modules, 46 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package contextargs implements a generic entity for shared context within workflows

All templates within a workflow shares the same cookiejar and a key-value store with shared items

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateVariables

func GenerateVariables(ctx *Context) map[string]interface{}

GenerateVariables from context args

Types

type Context

type Context struct {

	// Meta is the target for the executor
	MetaInput *MetaInput

	// CookieJar shared within workflow's http templates
	CookieJar *cookiejar.Jar
	// contains filtered or unexported fields
}

Context implements a shared context struct to share information across multiple templates within a workflow

func GetCopyIfHostOutdated added in v3.2.8

func GetCopyIfHostOutdated(ctx *Context, url string) *Context

GetCopyIfHostOutdated returns a new contextargs if the host is outdated

func New

func New(ctx context.Context) *Context

Create a new contextargs instance

func NewWithInput

func NewWithInput(ctx context.Context, input string) *Context

Create a new contextargs instance with input string

func NewWithMetaInput added in v3.2.8

func NewWithMetaInput(ctx context.Context, input *MetaInput) *Context

NewWithMetaInput creates a new contextargs instance with meta input

func (*Context) Add

func (ctx *Context) Add(key string, v interface{})

Add the specific key-value pair

func (*Context) Clone

func (ctx *Context) Clone() *Context

func (*Context) Context added in v3.2.5

func (ctx *Context) Context() context.Context

Context returns the context of the current contextargs

func (*Context) ForEach

func (ctx *Context) ForEach(f func(string, interface{}))

func (*Context) Get

func (ctx *Context) Get(key string) (interface{}, bool)

Get the value with specific key if exists

func (*Context) GetAll

func (ctx *Context) GetAll() map[string]interface{}

func (*Context) GetTemplateVariables added in v3.10.0

func (ctx *Context) GetTemplateVariables() map[string]interface{}

GetTemplateVariables returns values currently owned by template variable evaluation.

func (*Context) Has

func (ctx *Context) Has(key string) bool

Has check if the key exists

func (*Context) HasArgs

func (ctx *Context) HasArgs() bool

func (*Context) Merge

func (ctx *Context) Merge(args map[string]interface{})

Merge the key-value pairs

func (*Context) MergeTemplateVariables added in v3.10.0

func (ctx *Context) MergeTemplateVariables(args map[string]interface{})

MergeTemplateVariables merges values produced from template variables.

func (*Context) Port

func (ctx *Context) Port() string

Port returns the port of the target

func (*Context) Set

func (ctx *Context) Set(key string, value interface{})

Set the specific key-value pair

func (*Context) UseNetworkPort

func (ctx *Context) UseNetworkPort(port string, excludePorts string) error

UseNetworkPort updates input with required/default network port for that template. The template port is used when:

  • the input has no port at all, OR
  • the input port is a reserved HTTP/DNS port AND the port was not explicitly specified by the user (i.e. the input contains a URL scheme, meaning the port was implied by the scheme, not typed by the operator).

When the operator explicitly writes "target:80" (no scheme), that port is intentional (e.g. an SSH service running on port 80) and must not be replaced.

type MetaInput

type MetaInput struct {
	// Input represent the target
	Input string `json:"input,omitempty"`
	// CustomIP to use for connection
	CustomIP string `json:"customIP,omitempty"`

	// ReqResp is the raw request for the input
	ReqResp *types.RequestResponse `json:"raw-request,omitempty"`
	// contains filtered or unexported fields
}

MetaInput represents a target with metadata (TODO: replace with https://github.com/projectdiscovery/metainput)

func NewMetaInput added in v3.3.0

func NewMetaInput() *MetaInput

func (*MetaInput) Address added in v3.2.8

func (metaInput *MetaInput) Address() string

Address return the remote address of target Note: it does not resolve the domain to ip it is meant to be used by hosterrorsCache if invalid metainput is provided then it uses a random ksuid as hostname to avoid skipping valid targets

func (*MetaInput) Clone

func (metaInput *MetaInput) Clone() *MetaInput

func (*MetaInput) GetScanHash

func (metaInput *MetaInput) GetScanHash(templateId string) string

GetScanHash returns a unique hash that represents a scan by hashing (metainput + templateId)

func (*MetaInput) ID

func (metaInput *MetaInput) ID() string

ID returns a unique id/hash for metainput

func (*MetaInput) MarshalBytes

func (metaInput *MetaInput) MarshalBytes() ([]byte, error)

func (*MetaInput) MarshalString

func (metaInput *MetaInput) MarshalString() (string, error)

func (*MetaInput) MustMarshalBytes

func (metaInput *MetaInput) MustMarshalBytes() []byte

func (*MetaInput) MustMarshalString

func (metaInput *MetaInput) MustMarshalString() string

func (*MetaInput) Port added in v3.2.8

func (metaInput *MetaInput) Port() string

Port returns the port of the target if port is not present then empty string is returned

func (*MetaInput) PrettyPrint

func (metaInput *MetaInput) PrettyPrint() string

func (*MetaInput) Target added in v3.2.0

func (metaInput *MetaInput) Target() string

Target returns the target of the metainput

func (*MetaInput) URL added in v3.2.0

func (metaInput *MetaInput) URL() (*urlutil.URL, error)

URL returns request url

func (*MetaInput) Unmarshal

func (metaInput *MetaInput) Unmarshal(data string) error

Jump to

Keyboard shortcuts

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