matchers

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConditionTypes = map[string]ConditionType{
	"and": ANDCondition,
	"or":  ORCondition,
}

ConditionTypes is a table for conversion of condition type from string.

View Source
var MatcherTypes = map[MatcherType]string{
	WordsMatcher: "word",
	RegexMatcher: "regex",
}

MatcherTypes is a table for conversion of matcher type from string.

Functions

This section is empty.

Types

type ConditionType

type ConditionType int

ConditionType is the type of condition for matcher

const (
	// ANDCondition matches responses with AND condition in arguments.
	ANDCondition ConditionType = iota + 1
	// ORCondition matches responses with AND condition in arguments.
	ORCondition
)

type Matcher

type Matcher struct {
	// description: |
	//   Type is the type of the matcher.
	Type MatcherTypeHolder `` /* 142-byte string literal not displayed */
	// description: |
	//   Condition is the optional condition between two matcher variables. By default,
	//   the condition is assumed to be OR.
	// values:
	//   - "and"
	//   - "or"
	Condition string `` /* 150-byte string literal not displayed */

	// description: |
	//   Part is the part of the request response to match data from.
	//
	//   Each protocol exposes a lot of different parts which are well
	//   documented in docs for each request type.
	// examples:
	//   - value: "\"body\""
	//   - value: "\"raw\""
	Part string `yaml:"part,omitempty" jsonschema:"title=part of response to match,description=Part of response to match data from"`

	// description: |
	//   Name of the matcher. Name should be lowercase and must not contain
	//   spaces or underscores (_).
	// examples:
	//   - value: "\"cookie-matcher\""
	Name string `yaml:"name,omitempty" jsonschema:"title=name of the matcher,description=Name of the matcher"`
	// description: |
	//   Words contains word patterns required to be present in the response part.
	// examples:
	//   - name: Match for Outlook mail protection domain
	//     value: >
	//       []string{"mail.protection.outlook.com"}
	//   - name: Match for application/json in response headers
	//     value: >
	//       []string{"application/json"}
	Words []string `` /* 154-byte string literal not displayed */
	// description: |
	//   Regex contains Regular Expression patterns required to be present in the response part.
	// examples:
	//   - name: Match for Linkerd Service via Regex
	//     value: >
	//       []string{`(?mi)^Via\\s*?:.*?linkerd.*$`}
	//   - name: Match for Open Redirect via Location header
	//     value: >
	//       []string{`(?m)^(?:Location\\s*?:\\s*?)(?:https?://|//)?(?:[a-zA-Z0-9\\-_\\.@]*)example\\.com.*$`}
	Regex []string `` /* 154-byte string literal not displayed */
	// description: |
	//   DSL are the dsl expressions that will be evaluated as part of nuclei matching rules.
	//   A list of these helper functions are available [here](https://nuclei.projectdiscovery.io/templating-guide/helper-functions/).
	// examples:
	//   - name: DSL Matcher for package.json file
	//     value: >
	//       []string{"contains(body, 'packages') && contains(tolower(all_headers), 'application/octet-stream') && status_code == 200"}
	//   - name: DSL Matcher for missing strict transport security header
	//     value: >
	//       []string{"!contains(tolower(all_headers), ”strict-transport-security”)"}
	MatchAll bool `yaml:"match-all,omitempty" jsonschema:"title=match all values,description=match all matcher values ignoring condition"`
	Group    int  `yaml:"group,omitempty"`
	Alias    bool `yaml:"alias,omitempty"`
	// contains filtered or unexported fields
}

func (*Matcher) CompileMatchers

func (matcher *Matcher) CompileMatchers() error

func (*Matcher) GetType

func (matcher *Matcher) GetType() MatcherType

GetType returns the type of the matcher

func (*Matcher) MatchRegex

func (matcher *Matcher) MatchRegex(corpus string) (bool, []string)

MatchRegex matches a regex check against a corpus

func (*Matcher) MatchWords

func (matcher *Matcher) MatchWords(corpus string, data map[string]interface{}) (bool, []string)

func (*Matcher) ResultWithMatchedSnippet

func (matcher *Matcher) ResultWithMatchedSnippet(data bool, matchedSnippet []string) (bool, []string)

ResultWithMatchedSnippet returns true and the matched snippet, or false and an empty string

func (*Matcher) Validate

func (matcher *Matcher) Validate() error

Validate perform initial validation on the matcher structure

type MatcherType

type MatcherType int

MatcherType is the type of the matcher specified

const (
	// name:word
	WordsMatcher MatcherType = iota + 1
	// name:regex
	RegexMatcher
)

name:MatcherType

func (MatcherType) String

func (t MatcherType) String() string

type MatcherTypeHolder

type MatcherTypeHolder struct {
	MatcherType MatcherType `mapping:"true"`
}

MatcherTypeHolder is used to hold internal type of the matcher

func (MatcherTypeHolder) MarshalJSON

func (holder MatcherTypeHolder) MarshalJSON() ([]byte, error)

func (MatcherTypeHolder) MarshalYAML

func (holder MatcherTypeHolder) MarshalYAML() (interface{}, error)

func (MatcherTypeHolder) String

func (t MatcherTypeHolder) String() string

func (*MatcherTypeHolder) UnmarshalYAML

func (holder *MatcherTypeHolder) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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