Documentation ¶
Index ¶
- Variables
- type ConditionType
- type Matcher
- func (matcher *Matcher) CompileMatchers() error
- func (matcher *Matcher) GetType() MatcherType
- func (matcher *Matcher) MatchHash(corpus string) (bool, []string)
- func (matcher *Matcher) MatchRegex(corpus string) (bool, []string)
- func (matcher *Matcher) MatchStatusCode(statusCode int) bool
- func (matcher *Matcher) MatchWords(corpus string, data map[string]interface{}) (bool, []string)
- func (matcher *Matcher) Result(data bool) bool
- func (matcher *Matcher) ResultWithMatchedSnippet(data bool, matchedSnippet []string) (bool, []string)
- func (matcher *Matcher) Validate() error
- type MatcherType
- type MatcherTypeHolder
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) GetType ¶
func (matcher *Matcher) GetType() MatcherType
GetType returns the type of the matcher
func (*Matcher) MatchRegex ¶
MatchRegex matches a regex check against a corpus
func (*Matcher) MatchStatusCode ¶
MatchStatusCode matches a status code check against a corpus
func (*Matcher) MatchWords ¶
func (*Matcher) Result ¶
Result reverts the results of the match if the matcher is of type negative.
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
Click to show internal directories.
Click to hide internal directories.