Documentation ¶
Index ¶
- Constants
- type FTWConfiguration
- func (c *FTWConfiguration) WithLogMarkerHeaderName(name string)
- func (c *FTWConfiguration) WithLogfile(logfile string)
- func (c *FTWConfiguration) WithMaxMarkerLogLines(amount int)
- func (c *FTWConfiguration) WithMaxMarkerRetries(retries int)
- func (c *FTWConfiguration) WithOverrides(overrides FTWTestOverride)
- func (c *FTWConfiguration) WithRunMode(runMode RunMode)
- type FTWRegexp
- type FTWTestOverride
- type RunMode
Constants ¶
const ( // CloudRunMode is the string that will be used to override the run mode of execution to cloud CloudRunMode RunMode = "cloud" // DefaultRunMode is the default execution run mode DefaultRunMode RunMode = "default" // DefaultLogMarkerHeaderName is the default log marker header name DefaultLogMarkerHeaderName string = "X-CRS-Test" // DefaultMaxMarkerRetries is the default amount of retries that will be attempted to find the log markers DefaultMaxMarkerRetries int = 20 // DefaultMaxMarkerLogLines is the default lines we are going read back in a logfile to find the markers DefaultMaxMarkerLogLines int = 500 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FTWConfiguration ¶
type FTWConfiguration struct { // Logfile is the path to the file that contains the WAF logs to check. The path may be absolute or relative, in which case it will be interpreted as relative to the current working directory. LogFile string `koanf:"logfile"` // TestOverride holds the test overrides that will apply globally TestOverride FTWTestOverride `koanf:"testoverride"` // LogMarkerHeaderName is the name of the header that will be used by the test framework to mark positions in the log file LogMarkerHeaderName string `koanf:"logmarkerheadername"` // RunMode stores the mode used to interpret test results. See https://github.com/coreruleset/go-ftw#%EF%B8%8F-cloud-mode. RunMode RunMode `koanf:"mode"` // MaxMarkerRetries is the maximum number of times the search for log markers will be repeated; each time an additional request is sent to the web server, eventually forcing the log to be flushed MaxMarkerRetries int `koanf:"maxmarkerretries"` // MaxMarkerLogLines is the maximum number of lines to search for a marker before aborting MaxMarkerLogLines int `koanf:"maxmarkerloglines"` }
FTWConfiguration FTW global Configuration
func NewCloudConfig ¶ added in v0.5.0
func NewCloudConfig() *FTWConfiguration
NewCloudConfig initializes the configuration with cloud values
func NewConfigFromEnv ¶
func NewConfigFromEnv() (*FTWConfiguration, error)
NewConfigFromEnv reads configuration information from environment variables that start with `FTW_`
func NewConfigFromFile ¶
func NewConfigFromFile(cfgFile string) (*FTWConfiguration, error)
NewConfigFromFile reads configuration information from the config file if it exists, or uses `.ftw.yaml` as default file
func NewConfigFromString ¶
func NewConfigFromString(conf string) (*FTWConfiguration, error)
NewConfigFromString initializes the configuration from a yaml formatted string. Useful for testing.
func NewDefaultConfig ¶ added in v0.4.5
func NewDefaultConfig() *FTWConfiguration
NewDefaultConfig initializes the configuration with default values
func (*FTWConfiguration) WithLogMarkerHeaderName ¶ added in v0.4.5
func (c *FTWConfiguration) WithLogMarkerHeaderName(name string)
WithLogMarkerHeaderName sets the new LogMarker header name.
func (*FTWConfiguration) WithLogfile ¶ added in v0.4.5
func (c *FTWConfiguration) WithLogfile(logfile string)
WithLogfile changes the logfile in the configuration.
func (*FTWConfiguration) WithMaxMarkerLogLines ¶ added in v0.4.5
func (c *FTWConfiguration) WithMaxMarkerLogLines(amount int)
WithMaxMarkerLogLines sets the new amount of lines we go back in the logfile attempting to find markers.
func (*FTWConfiguration) WithMaxMarkerRetries ¶ added in v0.4.5
func (c *FTWConfiguration) WithMaxMarkerRetries(retries int)
WithMaxMarkerRetries sets the new amount of retries we are doing to find markers in the logfile.
func (*FTWConfiguration) WithOverrides ¶ added in v0.4.5
func (c *FTWConfiguration) WithOverrides(overrides FTWTestOverride)
WithOverrides sets the overrides in the configuration.
func (*FTWConfiguration) WithRunMode ¶ added in v0.4.5
func (c *FTWConfiguration) WithRunMode(runMode RunMode)
WithRunMode sets the RunMode.
type FTWRegexp ¶ added in v0.4.1
FTWRegexp is a wrapper around regexp.Regexp that implements the Unmarshaler interface
func NewFTWRegexp ¶ added in v0.5.0
NewFTWRegexp creates a new FTWRegexp from a string
func (*FTWRegexp) MatchString ¶ added in v0.4.1
MatchString implements the MatchString method of the regexp.Regexp struct
func (*FTWRegexp) UnmarshalText ¶ added in v0.4.1
UnmarshalText implements the Unmarshaler interface
type FTWTestOverride ¶
type FTWTestOverride struct { Overrides test.Overrides `koanf:"input"` Ignore map[*FTWRegexp]string `koanf:"ignore"` ForcePass map[*FTWRegexp]string `koanf:"forcepass"` ForceFail map[*FTWRegexp]string `koanf:"forcefail"` }
FTWTestOverride holds four lists:
Overrides allows you to override input parameters in tests. An example usage is if you want to change the `dest_addr` of all tests to point to an external IP or host. Ignore is for tests you want to ignore. You should add a comment on why you ignore the test ForcePass is for tests you want to pass unconditionally. You should add a comment on why you force to pass the test ForceFail is for tests you want to fail unconditionally. You should add a comment on why you force to fail the test