bodyprocessors

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterPlugin

func RegisterPlugin(name string, fn func() BodyProcessor)

RegisterPlugin registers a body processor by name. If the body processor is already registered, it will be overwritten

Types

type BodyProcessor

type BodyProcessor interface {
	// Read will process the body and initialize the body processor
	// It will return an error if the body is not valid
	Read(reader io.Reader, options Options) error
	// Collections returns a map of collections, for example,
	// the ARGS_POST variables from the REQUEST_BODY.
	Collections() CollectionsMap
	// Find returns the values in the body based on the input string
	// A string might be an xpath, a regex, a variable name, etc
	// The find function is responsible of transforming the input
	// string into a valid usable expression
	Find(string) (map[string][]string, error)
	// VariableHook tells the transaction to hook a variable
	// to the body processor, it will execute Find
	// rather than read it from the collections map
	VariableHook() variables.RuleVariable
}

BodyProcessor interface is used to create body processors for different content-types. They are able to read the body, force a collection. Hook to some variable and return data based on special expressions like XPATH, JQ, etc.

func GetBodyProcessor

func GetBodyProcessor(name string) (BodyProcessor, error)

GetBodyProcessor returns a body processor by name If the body processor is not found, it returns an error

type CollectionsMap

type CollectionsMap map[variables.RuleVariable]map[string][]string

CollectionsMap is used to store results for collections, example: REQUEST_HEADERS:

cookies: [cookie1: value1, cookie2: value2]
user-agent: ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"]

type Options

type Options struct {
	// Mime is the type of the body, it may contain parameters
	// like charset, boundary, etc.
	Mime string
	// StoragePath is the path where the body will be stored
	StoragePath string
	// FileMode is the mode of the file that will be created
	FileMode fs.FileMode
}

Options are used by BodyProcessors to provide some settings like a path to store temporary files. Implementations may ignore the options.

Jump to

Keyboard shortcuts

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