2020-12-21 09:01:32 +00:00
|
|
|
package protocols
|
|
|
|
|
2020-12-23 15:16:42 +00:00
|
|
|
import (
|
2020-12-24 15:17:41 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
2020-12-23 15:16:42 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
2020-12-23 20:12:04 +00:00
|
|
|
"go.uber.org/ratelimit"
|
2020-12-23 15:16:42 +00:00
|
|
|
)
|
2020-12-23 10:46:16 +00:00
|
|
|
|
2020-12-23 15:16:42 +00:00
|
|
|
// Executer is an interface implemented any protocol based request generator.
|
|
|
|
type Executer interface {
|
2020-12-23 10:46:16 +00:00
|
|
|
// Compile compiles the request generators preparing any requests possible.
|
2020-12-23 15:16:42 +00:00
|
|
|
Compile(options ExecuterOptions) error
|
2020-12-21 22:24:55 +00:00
|
|
|
// Requests returns the total number of requests the rule will perform
|
|
|
|
Requests() int64
|
2020-12-24 15:17:41 +00:00
|
|
|
// Match performs matching operation for a matcher on model and returns true or false.
|
|
|
|
Match(data map[string]interface{}, matcher *matchers.Matcher) bool
|
|
|
|
// Extract performs extracting operation for a extractor on model and returns true or false.
|
|
|
|
Extract(data map[string]interface{}, matcher *extractors.Extractor) map[string]struct{}
|
2020-12-23 15:16:42 +00:00
|
|
|
// Execute executes the protocol requests and returns an output event channel.
|
|
|
|
Execute(input string) (bool, error)
|
|
|
|
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
|
|
|
|
ExecuteWithResults(input string) ([]output.Event, error)
|
2020-12-21 09:01:32 +00:00
|
|
|
}
|
2020-12-23 10:46:16 +00:00
|
|
|
|
2020-12-23 15:16:42 +00:00
|
|
|
// ExecuterOptions contains the configuration options for executer clients
|
|
|
|
type ExecuterOptions struct {
|
|
|
|
// Output is a writer interface for writing output events from executer.
|
|
|
|
Output output.Writer
|
2020-12-23 20:12:04 +00:00
|
|
|
// Options contains configuration options for the executer.
|
2020-12-23 15:16:42 +00:00
|
|
|
Options *types.Options
|
2020-12-23 20:12:04 +00:00
|
|
|
// RateLimiter is a rate-limiter for limiting sent number of requests.
|
|
|
|
RateLimiter ratelimit.Limiter
|
2020-12-23 10:46:16 +00:00
|
|
|
}
|