Documentation
¶
Index ¶
- Constants
- Variables
- func GetCloudConfigUpdatedAt() time.Time
- func GetMatchingBlockedIPKeys(ip string) []string
- func GetMatchingMonitoredIPKeys(ip string) []string
- func GetMatchingUserAgentKeys(userAgent string) []string
- func Init(environmentConfig *aikido_types.EnvironmentConfigData, ...) error
- func IsBlockingEnabled() bool
- func IsCompiledWithZenGo() bool
- func IsIPAllowed(ip string) bool
- func IsIPBlocked(ip string) (bool, string)
- func IsIPBypassed(ip string) bool
- func IsMonitoredUserAgent(userAgent string) bool
- func IsUserAgentBlocked(userAgent string) (bool, string)
- func IsUserBlocked(userID string) bool
- func IsZenDisabled() bool
- func IsZenLoaded() bool
- func ResetWarnOnce()
- func SetBlocking(blocking bool)
- func SetUserBlocked(userID string)
- func SetZenDisabled(disabled bool)
- func SetZenLoaded(loaded bool)
- func ShouldBlockHostname(hostname string) bool
- func ShouldProtect() bool
- func Uninit()
- func UpdateServiceConfig(cloudConfig *aikido_types.CloudConfigData, ...)
- func WarnIfNotProtected()
- type Endpoint
- type EndpointKey
- type RateLimiting
- type ServiceConfigData
- type UserAgentDetail
Constants ¶
const ( GuardEndpointEU = "https://guard.aikido.dev/" GuardEndpointUS = "https://guard.us.aikido.dev/" GuardEndpointME = "https://guard.me.aikido.dev/" RuntimeEndpoint = "https://runtime.aikido.dev/" )
const (
Version = "0.3.0"
)
Variables ¶
var CollectAPISchema bool
Functions ¶
func GetCloudConfigUpdatedAt ¶
func GetMatchingBlockedIPKeys ¶ added in v0.3.0
GetMatchingBlockedIPKeys returns the keys of all blocked IP lists that match the given IP.
func GetMatchingMonitoredIPKeys ¶ added in v0.3.0
GetMatchingMonitoredIPKeys returns the keys of all monitored IP lists that match the given IP.
func GetMatchingUserAgentKeys ¶ added in v0.3.0
GetMatchingUserAgentKeys returns the keys of all user agent detail patterns that match the given user agent.
func Init ¶
func Init(environmentConfig *aikido_types.EnvironmentConfigData, aikidoConfig *aikido_types.AikidoConfigData) error
Init initializes the configuration system, extracting region from token to determine default endpoint URL if not set. Returns an error if setting the log level fails.
func IsBlockingEnabled ¶
func IsBlockingEnabled() bool
func IsCompiledWithZenGo ¶ added in v0.2.0
func IsCompiledWithZenGo() bool
IsCompiledWithZenGo returns true if the binary was compiled with zen-go toolexec.
func IsIPAllowed ¶
IsIPAllowed checks that the IP is allowed if the global allowed IP list is set. Private/local IP addresses are always allowed, even when an allow list is configured.
func IsIPBlocked ¶
IsIPBlocked function checks the cloud config mutex for blocked IP addresses.
func IsIPBypassed ¶
func IsMonitoredUserAgent ¶ added in v0.3.0
IsMonitoredUserAgent returns true if the user agent matches the monitored regex.
func IsUserAgentBlocked ¶
IsUserAgentBlocked returns true if we block (e.g. bot blocking), and a string with the reason why.
func IsUserBlocked ¶
func IsZenDisabled ¶
func IsZenDisabled() bool
func IsZenLoaded ¶
func IsZenLoaded() bool
func ResetWarnOnce ¶ added in v0.2.0
func ResetWarnOnce()
ResetWarnOnce resets the WarnIfNotProtected once guard.
func SetBlocking ¶
func SetBlocking(blocking bool)
func SetUserBlocked ¶
func SetUserBlocked(userID string)
func SetZenDisabled ¶
func SetZenDisabled(disabled bool)
func SetZenLoaded ¶
func SetZenLoaded(loaded bool)
func ShouldBlockHostname ¶
func ShouldProtect ¶
func ShouldProtect() bool
ShouldProtect returns true if protection should run. Protection runs when zen is not disabled AND has been loaded successfully.
func UpdateServiceConfig ¶
func UpdateServiceConfig(cloudConfig *aikido_types.CloudConfigData, blockListConfig *aikido_types.ListsConfigData)
func WarnIfNotProtected ¶ added in v0.2.0
func WarnIfNotProtected()
WarnIfNotProtected logs a warning once if zen.Protect() has not been called and Zen is not explicitly disabled. This helps customers notice when they have configured the middleware but forgotten to call zen.Protect().
Types ¶
type Endpoint ¶
type Endpoint struct {
Method string `json:"method"`
Route string `json:"route"`
ForceProtectionOff bool `json:"forceProtectionOff"`
Graphql any `json:"graphql"`
AllowedIPAddresses ipaddr.MatchList `json:"allowedIPAddresses"`
RateLimiting aikido_types.RateLimiting `json:"rateLimiting"`
}
func GetEndpoints ¶
func GetEndpoints() []Endpoint
type EndpointKey ¶
type RateLimiting ¶
type ServiceConfigData ¶
type ServiceConfigData struct {
ConfigUpdatedAt time.Time
Endpoints []Endpoint
BlockedUserIDs map[string]bool
BypassedIPs ipaddr.MatchList
AllowedIPs map[string]ipaddr.MatchList
BlockedIPs map[string]ipaddr.MatchList
MonitoredIPs map[string]ipaddr.MatchList
BlockedUserAgents *regexp.Regexp
MonitoredUserAgents *regexp.Regexp
UserAgentDetails []UserAgentDetail
Block bool
BlockNewOutgoingRequests bool
Domains []aikido_types.OutboundDomain
}