matchers

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 12 Imported by: ? modules, 0 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

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",
	HashMatcher:   "hash",
	StatusMatcher: "status",
}

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”)"}
	Hash []string `yaml:"hash,omitempty" jsonschema:"title=hash to match in response"`
	// description: |
	//   Status are the acceptable status codes for the response.
	// examples:
	//   - value: >
	//       []int{200, 302}
	Status     []int  `` /* 127-byte string literal not displayed */
	MatchAll   bool   `yaml:"match-all,omitempty" jsonschema:"title=match all values,description=match all matcher values ignoring condition"`
	HashMethod string `yaml:"hash-method"`
	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) MatchHash added in v1.4.4

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

MatchHash returns true if the corpus matches the favicon

func (*Matcher) MatchRegex

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

MatchRegex matches a regex check against a corpus

func (*Matcher) MatchStatusCode added in v1.5.4

func (matcher *Matcher) MatchStatusCode(statusCode int) bool

MatchStatusCode matches a status code check against a corpus

func (*Matcher) MatchWords

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

func (*Matcher) Result added in v1.5.4

func (matcher *Matcher) Result(data bool) bool

Result reverts the results of the match if the matcher is of type negative.

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
	HashMatcher
	StatusMatcher
)

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