go-agent: github.com/sqreen/go-agent/agent/internal Index | Files | Directories

package internal

import "github.com/sqreen/go-agent/agent/internal"


Package Files

agent.go batch.go client.go command.go metrics.go request.go version.go

func Start Uses

func Start()

Start the agent when enabled and back-off restart it when unhandled errors or panics occur.

The algorithm is based on multiple levels of try/catch equivalents called here "safe calls": - Level 1: a safe goroutine loop retrying the agent in case of unhandled

error or panic.

- Level 2: a safe call to the agent initialization. - Level 3: a safe call to the agent main loop. - Level 4, implicit here: internal agent errors that can be directly

handled by the agent without having to stop it.

Each level catches unhandled errors or panics of lower levels: - When the agent's main loop fails, it is caught and returned to the upper

level to try to send it in a separate safe call, as the agent is no
longer considered reliable.

- If a panic occurs in this overall agent error handling, everything is

considered unreliable and therefore aborted.

- Otherwise, the overall agent initialization and main loop is re-executed

with a backoff sleep.

- If this backoff-retry loop fails, the outer-most safe goroutine captures

it an silently return.

func TrySendAppException Uses

func TrySendAppException(logger plog.DebugLogger, cfg *config.Config, exception error)

TrySendAppException is a special client function allowing to send app-level exceptions

func UserEventMetricsStoreKey Uses

func UserEventMetricsStoreKey(event *userEvent) (json.Marshaler, error)

func ValidateCredentialsConfiguration Uses

func ValidateCredentialsConfiguration(token, appName string) (err error)

type Agent Uses

type Agent struct {
    // contains filtered or unexported fields

func New Uses

func New(cfg *config.Config) *Agent

func (*Agent) ActionsReload Uses

func (a *Agent) ActionsReload() error

func (*Agent) AddExceptionEvent Uses

func (a *Agent) AddExceptionEvent(e *ExceptionEvent)

func (*Agent) AddHTTPRequestRecordEvent Uses

func (a *Agent) AddHTTPRequestRecordEvent(e *HTTPRequestRecordEvent)

func (*Agent) GracefulStop Uses

func (a *Agent) GracefulStop()

func (*Agent) InstrumentationDisable Uses

func (a *Agent) InstrumentationDisable() error

InstrumentationDisable disables the agent instrumentation, which includes for now the SDK.

func (*Agent) InstrumentationEnable Uses

func (a *Agent) InstrumentationEnable() error

func (*Agent) NewRequestRecord Uses

func (a *Agent) NewRequestRecord(req *http.Request) types.RequestRecord

func (*Agent) RulesReload Uses

func (a *Agent) RulesReload() error

func (*Agent) RulespackID Uses

func (a *Agent) RulespackID() string

func (*Agent) Serve Uses

func (a *Agent) Serve() error

func (*Agent) SetCIDRWhitelist Uses

func (a *Agent) SetCIDRWhitelist(cidrs []string) error

type CommandHandler Uses

type CommandHandler func(args []json.RawMessage) error

CommandHandler is a function pointer type to a command handler. Command arguments need to be validated by the handler itself.

type CommandManager Uses

type CommandManager struct {
    // contains filtered or unexported fields

func NewCommandManager Uses

func NewCommandManager(agent CommandManagerAgent, logger *plog.Logger) *CommandManager

func (*CommandManager) ActionsReload Uses

func (m *CommandManager) ActionsReload([]json.RawMessage) error

func (*CommandManager) Do Uses

func (m *CommandManager) Do(commands []api.CommandRequest) map[string]api.CommandResult

func (*CommandManager) IPSWhitelist Uses

func (m *CommandManager) IPSWhitelist(args []json.RawMessage) error

func (*CommandManager) InstrumentationEnable Uses

func (m *CommandManager) InstrumentationEnable([]json.RawMessage) error

func (*CommandManager) InstrumentationRemove Uses

func (m *CommandManager) InstrumentationRemove([]json.RawMessage) error

func (*CommandManager) RulesReload Uses

func (m *CommandManager) RulesReload([]json.RawMessage) error

type CommandManagerAgent Uses

type CommandManagerAgent interface {
    InstrumentationEnable() error
    InstrumentationDisable() error
    ActionsReload() error
    SetCIDRWhitelist([]string) error
    RulesReload() error

CommandManagerAgent defines the expected agent SDK and allows to easily implement functional tests by mocking it up.

type Event Uses

type Event interface{}

type EventPropertyMap Uses

type EventPropertyMap map[string]string

type EventUserIdentifiersMap Uses

type EventUserIdentifiersMap map[string]string

type ExceptionEvent Uses

type ExceptionEvent struct {
    // contains filtered or unexported fields

func NewExceptionEvent Uses

func NewExceptionEvent(err error, rulespackID string) *ExceptionEvent

func (*ExceptionEvent) GetBacktrace Uses

func (e *ExceptionEvent) GetBacktrace() []api.StackFrame

func (*ExceptionEvent) GetContext Uses

func (e *ExceptionEvent) GetContext() api.ExceptionContext

func (*ExceptionEvent) GetKlass Uses

func (e *ExceptionEvent) GetKlass() string

func (*ExceptionEvent) GetMessage Uses

func (e *ExceptionEvent) GetMessage() string

func (*ExceptionEvent) GetRulespackID Uses

func (e *ExceptionEvent) GetRulespackID() string

func (*ExceptionEvent) GetTime Uses

func (e *ExceptionEvent) GetTime() time.Time

type HTTPRequestEvent Uses

type HTTPRequestEvent struct {
    // contains filtered or unexported fields

func (*HTTPRequestEvent) GetArgs Uses

func (e *HTTPRequestEvent) GetArgs() (args api.RequestRecord_Observed_SDKEvent_Args)

func (*HTTPRequestEvent) GetEvent Uses

func (e *HTTPRequestEvent) GetEvent() string

func (*HTTPRequestEvent) GetName Uses

func (e *HTTPRequestEvent) GetName() string

func (*HTTPRequestEvent) GetOptions Uses

func (e *HTTPRequestEvent) GetOptions() *api.RequestRecord_Observed_SDKEvent_Args_Track_Options

func (*HTTPRequestEvent) GetProperties Uses

func (e *HTTPRequestEvent) GetProperties() *api.Struct

func (*HTTPRequestEvent) GetTime Uses

func (e *HTTPRequestEvent) GetTime() time.Time

func (*HTTPRequestEvent) GetUserIdentifiers Uses

func (e *HTTPRequestEvent) GetUserIdentifiers() *api.Struct

func (*HTTPRequestEvent) WithProperties Uses

func (e *HTTPRequestEvent) WithProperties(p types.EventProperties)

func (*HTTPRequestEvent) WithTimestamp Uses

func (e *HTTPRequestEvent) WithTimestamp(t time.Time)

func (*HTTPRequestEvent) WithUserIdentifiers Uses

func (e *HTTPRequestEvent) WithUserIdentifiers(id map[string]string)

type HTTPRequestRecord Uses

type HTTPRequestRecord struct {
    // contains filtered or unexported fields

func (*HTTPRequestRecord) Close Uses

func (ctx *HTTPRequestRecord) Close()

func (*HTTPRequestRecord) Identify Uses

func (ctx *HTTPRequestRecord) Identify(id map[string]string)

func (*HTTPRequestRecord) NewCustomEvent Uses

func (ctx *HTTPRequestRecord) NewCustomEvent(event string) types.CustomEvent

func (*HTTPRequestRecord) NewUserAuth Uses

func (ctx *HTTPRequestRecord) NewUserAuth(id map[string]string, loginSuccess bool)

func (*HTTPRequestRecord) NewUserSignup Uses

func (ctx *HTTPRequestRecord) NewUserSignup(id map[string]string)

func (*HTTPRequestRecord) SecurityResponse Uses

func (ctx *HTTPRequestRecord) SecurityResponse() http.Handler

func (*HTTPRequestRecord) UserSecurityResponse Uses

func (ctx *HTTPRequestRecord) UserSecurityResponse() http.Handler

func (*HTTPRequestRecord) Whitelisted Uses

func (ctx *HTTPRequestRecord) Whitelisted() bool

type HTTPRequestRecordEvent Uses

type HTTPRequestRecordEvent struct {
    // contains filtered or unexported fields

func NewHTTPRequestRecordEvent Uses

func NewHTTPRequestRecordEvent(rr *HTTPRequestRecord, rulespackID string) *HTTPRequestRecordEvent

func (*HTTPRequestRecordEvent) GetClientIp Uses

func (r *HTTPRequestRecordEvent) GetClientIp() string

func (*HTTPRequestRecordEvent) GetObserved Uses

func (r *HTTPRequestRecordEvent) GetObserved() api.RequestRecord_Observed

func (*HTTPRequestRecordEvent) GetRequest Uses

func (r *HTTPRequestRecordEvent) GetRequest() api.RequestRecord_Request

func (*HTTPRequestRecordEvent) GetResponse Uses

func (r *HTTPRequestRecordEvent) GetResponse() api.RequestRecord_Response

func (*HTTPRequestRecordEvent) GetRulespackId Uses

func (r *HTTPRequestRecordEvent) GetRulespackId() string

func (*HTTPRequestRecordEvent) GetVersion Uses

func (r *HTTPRequestRecordEvent) GetVersion() string

type InvalidCredentialsConfiguration Uses

type InvalidCredentialsConfiguration struct {
    // contains filtered or unexported fields

func (InvalidCredentialsConfiguration) Cause Uses

func (e InvalidCredentialsConfiguration) Cause() error

func (InvalidCredentialsConfiguration) Unwrap Uses

func (e InvalidCredentialsConfiguration) Unwrap() error

type LoginError Uses

type LoginError struct {
    // contains filtered or unexported fields

func NewLoginError Uses

func NewLoginError(err error) LoginError

func (LoginError) Cause Uses

func (e LoginError) Cause() error

func (LoginError) Error Uses

func (e LoginError) Error() string

func (LoginError) Unwrap Uses

func (e LoginError) Unwrap() error

type WhitelistedHTTPRequestRecord Uses

type WhitelistedHTTPRequestRecord struct{}

WhitelistedHTTPRequestRecord is a request record whose methods do nothing in order to whitelist the request.

func (WhitelistedHTTPRequestRecord) Close Uses

func (WhitelistedHTTPRequestRecord) Close()

func (WhitelistedHTTPRequestRecord) Identify Uses

func (WhitelistedHTTPRequestRecord) Identify(map[string]string)

func (WhitelistedHTTPRequestRecord) NewCustomEvent Uses

func (r WhitelistedHTTPRequestRecord) NewCustomEvent(string) types.CustomEvent

func (WhitelistedHTTPRequestRecord) NewUserAuth Uses

func (WhitelistedHTTPRequestRecord) NewUserAuth(map[string]string, bool)

func (WhitelistedHTTPRequestRecord) NewUserSignup Uses

func (WhitelistedHTTPRequestRecord) NewUserSignup(map[string]string)

func (WhitelistedHTTPRequestRecord) SecurityResponse Uses

func (WhitelistedHTTPRequestRecord) SecurityResponse() http.Handler

func (WhitelistedHTTPRequestRecord) UserSecurityResponse Uses

func (WhitelistedHTTPRequestRecord) UserSecurityResponse() http.Handler

func (WhitelistedHTTPRequestRecord) Whitelisted Uses

func (WhitelistedHTTPRequestRecord) Whitelisted() bool

func (WhitelistedHTTPRequestRecord) WithProperties Uses

func (WhitelistedHTTPRequestRecord) WithProperties(types.EventProperties)

func (WhitelistedHTTPRequestRecord) WithTimestamp Uses

func (WhitelistedHTTPRequestRecord) WithTimestamp(time.Time)

func (WhitelistedHTTPRequestRecord) WithUserIdentifiers Uses

func (WhitelistedHTTPRequestRecord) WithUserIdentifiers(map[string]string)


actorPackage actor manages and associates IP addresses or user IDs to security actions such as redirecting, blacklisting or whitelisting.
metricsPackage metrics provides shared metrics stores.
ruleThis package manages the rules by instantiating the callbacks and attaching them to their corresponding hooks.

Package internal imports 29 packages (graph) and is imported by 1 packages. Updated 2019-08-13. Refresh now. Tools for package owners.