Documentation
¶
Index ¶
- Constants
- Variables
- func IsTargetValid(url string) error
- func ParseTLS(certFile, keyFile string) (tls.Certificate, *x509.CertPool, error)
- type Auth
- type CaptureConfigError
- type CsvConf
- type CsvData
- type CustomCookie
- type EnvCaptureConf
- type EnvironmentNotDefinedError
- type FailedAssertion
- type Hammer
- type RegexCaptureConf
- type RequestError
- type Scenario
- type ScenarioResult
- type ScenarioStep
- type ScenarioStepResult
- type ScenarioValidationError
- type SourceType
- type Tag
- type TestAssertionOpt
- type TimeRunCount
Constants ¶
const ( // Types ErrorProxy = "proxyError" ErrorConn = "connectionError" ErrorUnkown = "unknownError" ErrorIntented = "intentedError" // Errors for created intentionally ErrorDns = "dnsError" ErrorParse = "parseError" ErrorAddr = "addressError" ErrorInvalidRequest = "invalidRequestError" // Reasons ReasonProxyFailed = "proxy connection refused" ReasonProxyTimeout = "proxy timeout" ReasonConnTimeout = "connection timeout" ReasonReadTimeout = "read timeout" ReasonConnRefused = "connection refused" // In gracefully stop, engine cancels the ongoing requests. // We can detect the canceled requests with the help of this. ReasonCtxCanceled = "context canceled" )
Constants for custom error types and reasons
const ( // Constants of the Load Types LoadTypeLinear = "linear" LoadTypeIncremental = "incremental" LoadTypeWaved = "waved" // EngineModes EngineModeDistinctUser = "distinct-user" EngineModeRepeatedUser = "repeated-user" EngineModeDdosify = "ddosify" // Default Values DefaultIterCount = 100 DefaultLoadType = LoadTypeLinear DefaultDuration = 10 DefaultTimeout = 5 DefaultMethod = http.MethodGet DefaultOutputType = "stdout" // TODO: get this value from report.OutputTypeStdout when import cycle resolved. DefaultSamplingCount = 3 DefaultSingleMode = true )
Constants for Hammer field values
const ( // Constants of the Protocol types ProtocolHTTP = "HTTP" ProtocolHTTPS = "HTTPS" // Constants of the Auth types AuthHttpBasic = "basic" // Should match environment variables, reference EnvironmentVariableRegexStr = `{{[a-zA-Z$][a-zA-Z0-9_().-]*}}` // Should match environment variables, definition, exact match EnvironmentVariableNameStr = `^[a-zA-Z][a-zA-Z0-9_-]*$` )
Constants for Scenario field values
Variables ¶
var SupportedProtocols = [...]string{ProtocolHTTP, ProtocolHTTPS}
SupportedProtocols should be updated whenever a new requester.Requester interface implemented
Functions ¶
func IsTargetValid ¶ added in v0.11.0
Types ¶
type Auth ¶
Auth struct should be able to include all necessary authentication realated data for supportedAuthentications.
type CaptureConfigError ¶ added in v0.11.0
type CaptureConfigError struct {
// contains filtered or unexported fields
}
func (CaptureConfigError) Error ¶ added in v0.11.0
func (sc CaptureConfigError) Error() string
func (CaptureConfigError) Unwrap ¶ added in v0.11.0
func (sc CaptureConfigError) Unwrap() error
type CsvConf ¶ added in v0.14.1
type CsvConf struct { Path string `json:"path"` Delimiter string `json:"delimiter"` SkipFirstLine bool `json:"skip_first_line"` Vars map[string]Tag `json:"vars"` // "0":"name", "1":"city","2":"team" SkipEmptyLine bool `json:"skip_empty_line"` AllowQuota bool `json:"allow_quota"` Order string `json:"order"` }
type CustomCookie ¶ added in v1.0.0
type CustomCookie struct { Name string `json:"name"` Value string `json:"value"` Domain string `json:"domain"` Path string `json:"path"` Expires string `json:"expires"` MaxAge int `json:"max_age"` HttpOnly bool `json:"http_only"` Secure bool `json:"secure"` Raw string `json:"raw"` }
TimeRunCount is the data structure to store manual load type data.
type EnvCaptureConf ¶ added in v0.11.0
type EnvCaptureConf struct { JsonPath *string `json:"json_path"` Xpath *string `json:"xpath"` RegExp *RegexCaptureConf `json:"regexp"` Name string `json:"as"` From SourceType `json:"from"` Key *string `json:"header_key"` CookieName *string `json:"cookie_name"` }
type EnvironmentNotDefinedError ¶ added in v0.11.0
type EnvironmentNotDefinedError struct {
// contains filtered or unexported fields
}
func (EnvironmentNotDefinedError) Error ¶ added in v0.11.0
func (sc EnvironmentNotDefinedError) Error() string
func (EnvironmentNotDefinedError) Unwrap ¶ added in v0.11.0
func (sc EnvironmentNotDefinedError) Unwrap() error
type FailedAssertion ¶ added in v0.14.0
type Hammer ¶
type Hammer struct { // Total iteration count IterationCount int // Type of the load. LoadType string // Total Duration of the test in seconds. TestDuration int // Duration (in second) - Request count map. Example: {10: 1500, 50: 400, ...} TimeRunCountMap TimeRunCount // Test Scenario Scenario Scenario // Proxy/Proxies to use Proxy proxy.Proxy // Destination of the results data. ReportDestination string // Dynamic field for extra parameters. Others map[string]interface{} // Debug mode on/off Debug bool // Sampling rate SamplingRate int // Connection reuse EngineMode string // Test Data Config TestDataConf map[string]CsvConf // Custom Cookies Cookies []CustomCookie // Custom Cookies Enabled CookiesEnabled bool // Test-wide assertions Assertions map[string]TestAssertionOpt // Engine runs single SingleMode bool }
Hammer is like a lighter for the engine. It includes attack metadata and all necessary data to initialize the internal services in the engine.
type RegexCaptureConf ¶ added in v0.11.0
type RequestError ¶
RequestError is our custom error struct created in the requester.Requester implementations.
func (*RequestError) Error ¶
func (e *RequestError) Error() string
Custom error message method of ScenarioError
type Scenario ¶
type Scenario struct { Steps []ScenarioStep Envs map[string]interface{} CsvVars []string // only for validation Data map[string]CsvData // populated data }
Scenario struct contains a list of ScenarioStep so scenario.ScenarioService can execute the scenario step by step.
type ScenarioResult ¶ added in v0.10.0
type ScenarioResult struct { // First request start time for the Scenario StartTime time.Time ProxyAddr *url.URL StepResults []*ScenarioStepResult // Dynamic field for extra data needs in response object consumers. Others map[string]interface{} }
ScenarioResult is corresponding to Scenario. Each Scenario has a ScenarioResult after the scenario is played.
type ScenarioStep ¶ added in v0.10.0
type ScenarioStep struct { // ID of the Item. Should be given by the client. ID uint16 // Name of the Item. Name string // Request Method Method string // Authentication Auth Auth // A TLS cert Cert tls.Certificate // A TLS cert pool CertPool *x509.CertPool // Request Headers Headers map[string]string // Request payload Payload string // Target URL URL string // Connection timeout duration of the request in seconds Timeout int // Sleep duration after running the step. Can be a time range like "300-500" or an exact duration like "350" in ms Sleep string // Protocol spesific request parameters. For ex: DisableRedirects:true for Http requests Custom map[string]interface{} // Envs to capture from response of this step EnvsToCapture []EnvCaptureConf // assertion expressions Assertions []string }
ScenarioStep represents one step of a Scenario. This struct should be able to include all necessary data in a network packet for SupportedProtocols.
type ScenarioStepResult ¶ added in v0.10.0
type ScenarioStepResult struct { // ID of the ScenarioStep StepID uint16 // Name of the ScenarioStep StepName string // Each request has a unique ID. RequestID uuid.UUID // Returned status code. Has different meaning for different protocols. StatusCode int // Time of the request call. RequestTime time.Time // Total duration. From request sending to full response receiving. Duration time.Duration // Response content length ContentLength int64 // Error occurred at request time. Err RequestError // Url Url string // Method Method string // Request Headers ReqHeaders http.Header // Request Body ReqBody []byte // Response Headers RespHeaders http.Header // Response Body RespBody []byte // Protocol spesific metrics. For ex: DNSLookupDuration: 1s for HTTP Custom map[string]interface{} // Usable envs in this step UsableEnvs map[string]interface{} // Captured envs in this step ExtractedEnvs map[string]interface{} // Failed captures and their reasons FailedCaptures map[string]string // Failed assertion rules and received values FailedAssertions []FailedAssertion }
ScenarioStepResult is corresponding to ScenarioStep.
type ScenarioValidationError ¶ added in v0.11.0
type ScenarioValidationError struct {
// contains filtered or unexported fields
}
func (ScenarioValidationError) Error ¶ added in v0.11.0
func (sc ScenarioValidationError) Error() string
func (ScenarioValidationError) Unwrap ¶ added in v0.11.0
func (sc ScenarioValidationError) Unwrap() error
type SourceType ¶ added in v0.11.0
type SourceType string
const ( Header SourceType = "header" Body SourceType = "body" Cookie SourceType = "cookies" )
type TestAssertionOpt ¶ added in v1.0.0
type TimeRunCount ¶ added in v0.6.0
TimeRunCount is the data structure to store manual load type data.