Documentation
¶
Index ¶
- Constants
- Variables
- func IPFromRequest(req *http.Request) (net.IP, error)
- type AdminAPIConfig
- type AdminAPIResponse
- type AdminAPIUser
- type CommandAPI
- type DumpFile
- type EndpointAPIConfig
- type EndpointDumps
- type EventStreamer
- type LogStream
- type Manager
- func (m *Manager) AddCommand(uuid string, c *api.EndpointCommand) error
- func (m *Manager) AddEndpoint(uuid, key string)
- func (m *Manager) CreateNewAdminAPIUser(user *AdminAPIUser) (err error)
- func (m *Manager) Endpoint(uuid string) (*api.Endpoint, bool)
- func (m *Manager) Endpoints() (endpoints []*api.Endpoint, err error)
- func (m *Manager) GetCommand(uuid string) (*api.EndpointCommand, error)
- func (m *Manager) ImportRules(directory string) (err error)
- func (m *Manager) IsDone() bool
- func (m *Manager) Run()
- func (m *Manager) Shutdown() (lastErr error)
- func (m *Manager) UpdateReducer(identifier string, e *event.EdrEvent)
- func (m *Manager) Wait()
- type ManagerConfig
- type ManagerLogConfig
- type TLSConfig
Constants ¶
const (
// IoCContainerName default container name to store manager's IoCs
IoCContainerName = "edr_iocs"
)
const (
MaxLimitLogAPI = 10000
)
Variables ¶
var ( // Used to specify a command timeout for command execution CommandTimeout = 15 * time.Second )
var ( // ErrUnkEndpoint error to return when endpoint is unknown ErrUnkEndpoint = fmt.Errorf("unknown endpoint") )
var OpenAPIDefinition = `` /* 195357-byte string literal not displayed */
Functions ¶
func IPFromRequest ¶
IPFromRequest extracts the user IP address from req, if present. source: https://blog.golang.org/context/userip/userip.go
Types ¶
type AdminAPIConfig ¶
type AdminAPIConfig struct {
Host string `toml:"host" comment:"Hostname or IP address where the API should listen to"`
Port int `toml:"port" comment:"Port used by the API"`
}
AdminAPIConfig configuration for Administrative API
type AdminAPIResponse ¶
type AdminAPIResponse struct {
Data interface{} `json:"data"`
Message string `json:"message"`
Error string `json:"error"`
}
AdminAPIResponse standard structure to encode any response from the AdminAPI
func NewAdminAPIRespError ¶
func NewAdminAPIRespError(err error) *AdminAPIResponse
NewAdminAPIRespError creates a new response from an error
func NewAdminAPIRespErrorString ¶
func NewAdminAPIRespErrorString(err string) *AdminAPIResponse
NewAdminAPIRespErrorString creates a new error response from an error
func NewAdminAPIResponse ¶
func NewAdminAPIResponse(data interface{}) *AdminAPIResponse
NewAdminAPIResponse creates a new response from data
func (*AdminAPIResponse) Err ¶
func (r *AdminAPIResponse) Err() error
Err returns a response Error field in a form of a Go error
func (*AdminAPIResponse) ToJSON ¶
func (r *AdminAPIResponse) ToJSON() []byte
ToJSON serializes the response to JSON
func (*AdminAPIResponse) UnmarshalData ¶
func (r *AdminAPIResponse) UnmarshalData(i interface{}) error
UnmarshalData unmarshals the Data field of the response to an interface
type AdminAPIUser ¶
type AdminAPIUser struct {
sod.Item
Uuid string `json:"uuid" sod:"unique"`
Identifier string `json:"identifier" sod:"unique"`
Key string `json:"key,omitempty" sod:"unique"`
Group string `json:"group" sod:"index"`
Description string `json:"description"`
}
AdminAPIUser structure definition
type CommandAPI ¶
type CommandAPI struct {
CommandLine string `json:"command-line"`
FetchFiles []string `json:"fetch-files"`
DropFiles []string `json:"drop-files"`
Timeout time.Duration `json:"timeout"`
}
CommandAPI structure used by Admin API clients to POST commands
func (*CommandAPI) ToCommand ¶
func (c *CommandAPI) ToCommand() (*api.EndpointCommand, error)
ToCommand converts a CommandAPI to an EndpointCommand
type EndpointAPIConfig ¶
type EndpointAPIConfig struct {
Host string `toml:"host" comment:"Hostname or IP where the API should listen to"`
Port int `toml:"port" comment:"Port used by the API"`
ServerKey string `` /* 162-byte string literal not displayed */
}
EndpointAPIConfig structure holding configuration for the API used by endpoints
type EndpointDumps ¶
type EventStreamer ¶
func NewEventStreamer ¶
func NewEventStreamer() *EventStreamer
func (*EventStreamer) NewStream ¶
func (s *EventStreamer) NewStream() *LogStream
func (*EventStreamer) Queue ¶
func (s *EventStreamer) Queue(e *event.EdrEvent)
type Manager ¶
type Manager struct {
sync.RWMutex
/* Public */
Config *ManagerConfig
// contains filtered or unexported fields
}
Manager structure definition
func NewManager ¶
func NewManager(c *ManagerConfig) (*Manager, error)
NewManager creates a new WHIDS manager with a logfile as parameter
func (*Manager) AddCommand ¶
func (m *Manager) AddCommand(uuid string, c *api.EndpointCommand) error
AddCommand sets a command to be executed on endpoint specified by UUID
func (*Manager) AddEndpoint ¶
AddEndpoint adds new endpoint to the manager
func (*Manager) CreateNewAdminAPIUser ¶
func (m *Manager) CreateNewAdminAPIUser(user *AdminAPIUser) (err error)
CreateNewAdminAPIUser creates a new user in the user able to access admin API in database.
func (*Manager) Endpoint ¶
Endpoint returns an Endpoint pointer from database Result must be handled with care as any change to the Endpoint might be commited to the database. If an Endpoint needs to be modified but changes don't need to be commited, use Endpoint.Copy() to work on a copy
func (*Manager) Endpoints ¶
Endpoints returns a slice of Endpoint pointers from database Result must be handled with care as any change to the Endpoint might be commited to the database. If an Endpoint needs to be modified but changes don't need to be commited, use Endpoint.Copy() to work on a copy
func (*Manager) GetCommand ¶
func (m *Manager) GetCommand(uuid string) (*api.EndpointCommand, error)
GetCommand gets the command set for an endpoint specified by UUID
func (*Manager) ImportRules ¶
func (*Manager) UpdateReducer ¶
UpdateReducer updates the reducer member of the Manager
type ManagerConfig ¶
type ManagerConfig struct {
// TOML strings need to be first otherwise issue parsing back config
Database string `toml:"db" comment:"Path to store database"`
Repair bool `toml:"repair-db" comment:"Attempt to repair broken database"`
DumpDir string `toml:"dump-dir" comment:"Directory where to dump artifacts collected on hosts"`
AdminAPI AdminAPIConfig `toml:"admin-api" comment:"Settings to configure administrative API (not supposed to be reachable by endpoints)"`
EndpointAPI EndpointAPIConfig `toml:"endpoint-api" comment:"Settings to configure API used by endpoints"`
Logging ManagerLogConfig `toml:"logging" comment:"Logging settings"`
TLS TLSConfig `toml:"tls" comment:"TLS settings. Leave empty, not to use TLS"`
// contains filtered or unexported fields
}
ManagerConfig defines manager's configuration structure
func LoadManagerConfig ¶
func LoadManagerConfig(path string) (*ManagerConfig, error)
LoadManagerConfig loads the manager configuration from a file
func (*ManagerConfig) AdminAPIUrl ¶
func (mc *ManagerConfig) AdminAPIUrl() string
EndpointAPIUrl returns the URL of the Admin API
func (*ManagerConfig) EndpointAPIUrl ¶
func (mc *ManagerConfig) EndpointAPIUrl() string
EndpointAPIUrl returns the URL of the Endpoint API
func (*ManagerConfig) Save ¶
func (mc *ManagerConfig) Save() error
Save saves the configuration to a path specified by the path member of the structure
func (*ManagerConfig) SetPath ¶
func (mc *ManagerConfig) SetPath(path string)
SetPath exposes the path member for changes
type ManagerLogConfig ¶
type ManagerLogConfig struct {
Root string `toml:"root" comment:"Root directory where logfiles are stored"`
LogBasename string `toml:"logfile" comment:"Logfile name (relative to root) used to store logs"`
VerboseHTTP bool `toml:"verbose-http" comment:"Enables verbose HTTP logs\n When disabled beaconing requests are filtered out"`
}
ManagerLogConfig structure to hold manager's logging configuration
type TLSConfig ¶
type TLSConfig struct {
Cert string `toml:"cert" comment:"Path to the certificate file to use for TLS connections"`
Key string `toml:"key" comment:"Path to the key to use for TLS connection"`
}
TLSConfig structure definition