metlo

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const MaxConnectTries int = 10
View Source
const MaxConnectionRetries int = 1000
View Source
const MaxRestartTries int = 10
View Source
const MetloDefaultRPS int = 100

Variables

View Source
var AgentConfigClient = &http.Client{Timeout: 5 * time.Second}

Functions

func CheckKeyValuePair added in v1.0.2

func CheckKeyValuePair(condOperator *string, condKey *string, condValue *string, keyValuePairs []NV) bool

func CheckStatusCode added in v1.0.2

func CheckStatusCode(condOperator *string, condStatusCode *string, reqStatusCode *int) bool

func CheckStringCondition added in v1.0.2

func CheckStringCondition(condOperator *string, condValue *string, reqValue *string) bool

func CheckUser added in v1.0.2

func CheckUser(condOperator *string, condValue *string, authentication *Authentication, user *string, headers []NV) bool

func GetConditionBoolean added in v1.0.2

func GetConditionBoolean(req TraceReq, traceMeta TraceMeta, condition ConditionItem, authentication *Authentication, statusCode *int) bool

func GetCookiesFromString added in v1.0.2

func GetCookiesFromString(cookieString string) []*http.Cookie

func GetIntervalDuration added in v1.0.2

func GetIntervalDuration(thresholdInterval string) time.Duration

func GetKeyValuePairValue added in v1.0.2

func GetKeyValuePairValue(key string, keyValuePairs []NV) *string

func GetRateLimitKey added in v1.0.2

func GetRateLimitKey(rule WafRule, req TraceReq, traceMeta TraceMeta, authentication *Authentication) string

func GetSourceIp added in v1.0.2

func GetSourceIp(reqHeaders []NV, traceMeta TraceMeta) *string

func GetWindowInfo added in v1.0.2

func GetWindowInfo(thresholdInterval string, thresholdStart time.Time, now time.Time) (float64, float64)

func GetXForwardedForFromValue added in v1.0.2

func GetXForwardedForFromValue(value *string) *string

func HandleBlockRule added in v1.0.2

func HandleBlockRule(req TraceReq, traceMeta TraceMeta, conditionGroups []ConditionGroup, authentication *Authentication, statusCode *int) bool

func HandleRateLimitRule added in v1.0.2

func HandleRateLimitRule(req TraceReq, traceMeta TraceMeta, rule WafRule, authentication *Authentication) bool

func HandleRateLimitRuleUpdate added in v1.0.2

func HandleRateLimitRuleUpdate(data MetloTrace, rule WafRule, authentication *Authentication)

func HandleRateLimitStateAction added in v1.0.2

func HandleRateLimitStateAction(ruleAction WafAction, key string, action RateLimitStateAction, entries map[string]RateLimitEntry)

func HandleSessionIdentifier added in v1.0.2

func HandleSessionIdentifier(authentication *Authentication, headers []NV, key *strings.Builder)

func HandleUserIdentifier added in v1.0.2

func HandleUserIdentifier(authentication *Authentication, headers []NV, user *string, key *strings.Builder)

func InitMetlo

func InitMetlo(metloHost string, metloKey string) *metlo

func InitMetloCustom

func InitMetloCustom(metloHost string, metloKey string, rps int, backendPort int, collectorPort int, encryptionKey *string, logLevel LogLevel, disable bool) *metlo

func IsConditionGroupMatch added in v1.0.2

func IsConditionGroupMatch(req TraceReq, traceMeta TraceMeta, conditionGroup ConditionGroup, authentication *Authentication, statusCode *int) bool

func MapLogLevelToString added in v1.0.1

func MapLogLevelToString(lvl LogLevel) string

func MapMetloTraceToMetloIngestRPC

func MapMetloTraceToMetloIngestRPC(trace MetloTrace) mi.ApiTrace

Types

type AgentConfig added in v1.0.2

type AgentConfig struct {
	WafConfig            *[]WafRule        `json:"wafConfig"`
	AuthenticationConfig *[]Authentication `json:"authenticationConfig"`
	HostMap              *[]HostMap        `json:"hostMap"`
}

type Authentication added in v1.0.2

type Authentication struct {
	Host           string  `json:"host"`
	AuthType       string  `json:"authType"`
	HeaderKey      *string `json:"headerKey"`
	JwtUserPath    *string `json:"jwtUserPath"`
	CookieName     *string `json:"cookieName"`
	UserCookieName *string `json:"userCookieName"`
}

type ConditionGroup added in v1.0.2

type ConditionGroup struct {
	Conditions []ConditionItem `json:"conditions"`
	Rule       string          `json:"rule"`
}

type ConditionItem added in v1.0.2

type ConditionItem struct {
	Field    string `json:"field"`
	Operator string `json:"operator"`
	Key      string `json:"key"`
	Value    string `json:"value"`
}

type HostMap added in v1.0.2

type HostMap struct {
	Host    string `json:"host"`
	Pattern string `json:"pattern"`
}

type HostMapCompiled added in v1.0.2

type HostMapCompiled struct {
	Host    string
	Pattern *regexp.Regexp
}

type LogLevel added in v1.0.1

type LogLevel int
const (
	Trace LogLevel = iota
	Debug
	Info
	Warn
	Error
)

type MetloTrace

type MetloTrace struct {
	Request  TraceReq  `json:"request"`
	Response TraceRes  `json:"response"`
	Meta     TraceMeta `json:"meta"`
}

type NV

type NV struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type RateLimitEntry added in v1.0.2

type RateLimitEntry struct {
	Threshold         uint16
	Duration          uint32
	DurationStart     *time.Time
	ThresholdStart    time.Time
	ThresholdInterval string
	Window            RateLimitWindow
}

type RateLimitMap added in v1.0.2

type RateLimitMap struct {
	// contains filtered or unexported fields
}

type RateLimitStateAction added in v1.0.2

type RateLimitStateAction int64
const (
	Create RateLimitStateAction = iota
	Reset
	Increment
)

type RateLimitWindow added in v1.0.2

type RateLimitWindow struct {
	Prev uint16
	Curr uint16
}

type TraceMeta

type TraceMeta struct {
	Environment     string `json:"environment"`
	Incoming        bool   `json:"incoming"`
	Source          string `json:"source"`
	SourcePort      int    `json:"sourcePort"`
	Destination     string `json:"destination"`
	DestinationPort int    `json:"destinationPort"`
	MetloSource     string `json:"metloSource"`
}

type TraceReq

type TraceReq struct {
	Url     TraceUrl `json:"url"`
	Headers []NV     `json:"headers"`
	Body    string   `json:"body"`
	Method  string   `json:"method"`
	User    *string  `json:"user"`
}

type TraceRes

type TraceRes struct {
	Status  int    `json:"status"`
	Headers []NV   `json:"headers"`
	Body    string `json:"body"`
}

type TraceUrl

type TraceUrl struct {
	Host       string `json:"host"`
	Path       string `json:"path"`
	Parameters []NV   `json:"parameters"`
}

type WafAction added in v1.0.2

type WafAction struct {
	ActionType   string        `json:"actionType"`
	RateLimit    *WafRateLimit `json:"rateLimit"`
	BlockEndTime *int64        `json:"blockEndTime"`
}

type WafConfig added in v1.0.2

type WafConfig struct {
	WafRules             []WafRule
	AuthenticationConfig []Authentication
	HostMap              []HostMapCompiled
	// contains filtered or unexported fields
}

type WafRateLimit added in v1.0.2

type WafRateLimit struct {
	Threshold uint16               `json:"threshold"`
	Interval  string               `json:"interval"`
	Duration  WafRateLimitDuration `json:"duration"`
}

type WafRateLimitDuration added in v1.0.2

type WafRateLimitDuration struct {
	Hour   uint32 `json:"hour"`
	Minute uint32 `json:"minute"`
	Second uint32 `json:"second"`
}

type WafRule added in v1.0.2

type WafRule struct {
	Uuid            string           `json:"uuid"`
	RuleType        string           `json:"ruleType"`
	TagName         *string          `json:"tagName"`
	Identifiers     *[]string        `json:"identifiers"`
	Action          *WafAction       `json:"action"`
	ConditionGroups []ConditionGroup `json:"conditionGroups"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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