service

package
v0.0.0-...-98a7958 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: MIT Imports: 49 Imported by: 0

Documentation

Overview

Package service holds the implementation of the kolide service interface and the HTTP endpoints for the API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHandler

func MakeHandler(svc kolide.Service, config config.KolideConfig, logger kitlog.Logger) http.Handler

MakeHandler creates an HTTP handler for the Fleet server endpoints.

func NewLoggingService

func NewLoggingService(svc kolide.Service, logger kitlog.Logger) kolide.Service

NewLoggingService takes an existing service and adds a logging wrapper

func NewMetricsService

func NewMetricsService(
	svc kolide.Service,
	requestCount metrics.Counter,
	requestLatency metrics.Histogram,
) kolide.Service

NewMetrics service takes an existing service and wraps it with instrumentation middleware.

func NewService

NewService creates a new service from the config struct

func RedirectLoginToSetup

func RedirectLoginToSetup(svc kolide.Service, logger kitlog.Logger, next http.Handler, urlPrefix string) http.HandlerFunc

RedirectLoginToSetup detects if the setup endpoint should be used. If setup is required it redirect all frontend urls to /setup, otherwise the frontend router is used.

func RedirectSetupToLogin

func RedirectSetupToLogin(svc kolide.Service, logger kitlog.Logger, next http.Handler, urlPrefix string) http.HandlerFunc

RedirectSetupToLogin forces the /setup path to be redirected to login. This middleware is used after the app has been setup.

func RequireSetup

func RequireSetup(svc kolide.Service) (bool, error)

RequireSetup checks to see if the service has been setup.

func ServeFrontend

func ServeFrontend(urlPrefix string, logger log.Logger) http.Handler

func ServeStaticAssets

func ServeStaticAssets(path string) http.Handler

func WithSetup

func WithSetup(svc kolide.Service, logger kitlog.Logger, next http.Handler) http.HandlerFunc

WithSetup is an http middleware that checks is setup procedures have been completed. If setup hasn't been completed it serves the API with a setup middleware. If the server is already configured, the default API handler is exposed.

Types

type Client

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

func NewClient

func NewClient(addr string, insecureSkipVerify bool, rootCA, urlPrefix string) (*Client, error)

func (*Client) ApplyAppConfig

func (c *Client) ApplyAppConfig(payload *kolide.AppConfigPayload) error

ApplyAppConfig sends the application config to be applied to the Fleet instance.

func (*Client) ApplyEnrollSecretSpec

func (c *Client) ApplyEnrollSecretSpec(spec *kolide.EnrollSecretSpec) error

ApplyEnrollSecretSpec applies the enroll secrets.

func (*Client) ApplyLabels

func (c *Client) ApplyLabels(specs []*kolide.LabelSpec) error

ApplyLabels sends the list of Labels to be applied (upserted) to the Fleet instance.

func (*Client) ApplyOptions

func (c *Client) ApplyOptions(spec *kolide.OptionsSpec) error

ApplyOptions sends the osquery options to be applied to the Fleet instance.

func (*Client) ApplyPacks

func (c *Client) ApplyPacks(specs []*kolide.PackSpec) error

ApplyPacks sends the list of Packs to be applied (upserted) to the Fleet instance.

func (*Client) ApplyQueries

func (c *Client) ApplyQueries(specs []*kolide.QuerySpec) error

ApplyQueries sends the list of Queries to be applied (upserted) to the Fleet instance.

func (*Client) AuthenticatedDo

func (c *Client) AuthenticatedDo(verb, path string, params interface{}) (*http.Response, error)

func (*Client) DeleteHost

func (c *Client) DeleteHost(id uint) error

DeleteHost deletes the host with the matching id.

func (*Client) DeleteLabel

func (c *Client) DeleteLabel(name string) error

DeleteLabel deletes the label with the matching name.

func (*Client) DeletePack

func (c *Client) DeletePack(name string) error

DeletePack deletes the pack with the matching name.

func (*Client) DeleteQuery

func (c *Client) DeleteQuery(name string) error

DeleteQuery deletes the query with the matching name.

func (*Client) Do

func (c *Client) Do(verb, path string, params interface{}) (*http.Response, error)

func (*Client) GetAppConfig

func (c *Client) GetAppConfig() (*kolide.AppConfigPayload, error)

GetAppConfig fetches the application config from the server API

func (*Client) GetEnrollSecretSpec

func (c *Client) GetEnrollSecretSpec() (*kolide.EnrollSecretSpec, error)

GetEnrollSecretSpec fetches the enroll secrets stored on the server

func (*Client) GetHosts

func (c *Client) GetHosts() ([]HostResponse, error)

GetHosts retrieves the list of all Hosts

func (*Client) GetLabel

func (c *Client) GetLabel(name string) (*kolide.LabelSpec, error)

GetLabel retrieves information about a label by name

func (*Client) GetLabels

func (c *Client) GetLabels() ([]*kolide.LabelSpec, error)

GetLabels retrieves the list of all Labels.

func (*Client) GetOptions

func (c *Client) GetOptions() (*kolide.OptionsSpec, error)

GetOptions retrieves the configured osquery options.

func (*Client) GetPack

func (c *Client) GetPack(name string) (*kolide.PackSpec, error)

GetPack retrieves information about a pack

func (*Client) GetPacks

func (c *Client) GetPacks() ([]*kolide.PackSpec, error)

GetPacks retrieves the list of all Packs.

func (*Client) GetQueries

func (c *Client) GetQueries() ([]*kolide.QuerySpec, error)

GetQueries retrieves the list of all Queries.

func (*Client) GetQuery

func (c *Client) GetQuery(name string) (*kolide.QuerySpec, error)

GetQuery retrieves the list of all Queries.

func (*Client) GetServerSettings

func (c *Client) GetServerSettings() (*kolide.ServerSettings, error)

GetServerSettings fetches the server settings from the server API

func (*Client) HostByIdentifier

func (c *Client) HostByIdentifier(identifier string) (*HostResponse, error)

HostByIdentifier retrieves a host by the uuid, osquery_host_id, hostname, or node_key.

func (*Client) LiveQuery

func (c *Client) LiveQuery(query string, labels []string, hosts []string) (*LiveQueryResultsHandler, error)

LiveQuery creates a new live query and begins streaming results.

func (*Client) Login

func (c *Client) Login(email, password string) (string, error)

Login attempts to login to the current Fleet instance. If login is successful, an auth token is returned.

func (*Client) Logout

func (c *Client) Logout() error

Logout attempts to logout to the current Fleet instance.

func (*Client) SearchTargets

func (c *Client) SearchTargets(query string, selectedHostIDs, selectedLabelIDs []uint) (*kolide.TargetSearchResults, error)

SearchTargets searches for the supplied targets in the Fleet instance.

func (*Client) SetToken

func (c *Client) SetToken(t string)

func (*Client) Setup

func (c *Client) Setup(email, username, password, org string) (string, error)

Setup attempts to setup the current Fleet instance. If setup is successful, an auth token is returned.

type HostResponse

type HostResponse struct {
	kolide.Host
	Status      kolide.HostStatus `json:"status"`
	DisplayText string            `json:"display_text"`
	Labels      []kolide.Label    `json:"labels,omitempty"`
}

HostResponse is the response struct that contains the full host information along with the host online status and the "display text" to be used when rendering in the UI.

type InvalidLoginErr

type InvalidLoginErr interface {
	InvalidLogin() bool
	Error() string
}

type KolideEndpoints

type KolideEndpoints struct {
	Login                                 endpoint.Endpoint
	Logout                                endpoint.Endpoint
	ForgotPassword                        endpoint.Endpoint
	ResetPassword                         endpoint.Endpoint
	Me                                    endpoint.Endpoint
	ChangePassword                        endpoint.Endpoint
	CreateUser                            endpoint.Endpoint
	GetUser                               endpoint.Endpoint
	ListUsers                             endpoint.Endpoint
	ModifyUser                            endpoint.Endpoint
	AdminUser                             endpoint.Endpoint
	EnableUser                            endpoint.Endpoint
	RequirePasswordReset                  endpoint.Endpoint
	PerformRequiredPasswordReset          endpoint.Endpoint
	GetSessionsForUserInfo                endpoint.Endpoint
	DeleteSessionsForUser                 endpoint.Endpoint
	GetSessionInfo                        endpoint.Endpoint
	DeleteSession                         endpoint.Endpoint
	GetAppConfig                          endpoint.Endpoint
	ModifyAppConfig                       endpoint.Endpoint
	ApplyEnrollSecretSpec                 endpoint.Endpoint
	GetEnrollSecretSpec                   endpoint.Endpoint
	CreateInvite                          endpoint.Endpoint
	ListInvites                           endpoint.Endpoint
	DeleteInvite                          endpoint.Endpoint
	VerifyInvite                          endpoint.Endpoint
	GetQuery                              endpoint.Endpoint
	ListQueries                           endpoint.Endpoint
	CreateQuery                           endpoint.Endpoint
	ModifyQuery                           endpoint.Endpoint
	DeleteQuery                           endpoint.Endpoint
	DeleteQueryByID                       endpoint.Endpoint
	DeleteQueries                         endpoint.Endpoint
	ApplyQuerySpecs                       endpoint.Endpoint
	GetQuerySpecs                         endpoint.Endpoint
	GetQuerySpec                          endpoint.Endpoint
	CreateDistributedQueryCampaign        endpoint.Endpoint
	CreateDistributedQueryCampaignByNames endpoint.Endpoint
	CreatePack                            endpoint.Endpoint
	ModifyPack                            endpoint.Endpoint
	GetPack                               endpoint.Endpoint
	ListPacks                             endpoint.Endpoint
	DeletePack                            endpoint.Endpoint
	DeletePackByID                        endpoint.Endpoint
	GetScheduledQueriesInPack             endpoint.Endpoint
	ScheduleQuery                         endpoint.Endpoint
	GetScheduledQuery                     endpoint.Endpoint
	ModifyScheduledQuery                  endpoint.Endpoint
	DeleteScheduledQuery                  endpoint.Endpoint
	ApplyPackSpecs                        endpoint.Endpoint
	GetPackSpecs                          endpoint.Endpoint
	GetPackSpec                           endpoint.Endpoint
	EnrollAgent                           endpoint.Endpoint
	GetClientConfig                       endpoint.Endpoint
	GetDistributedQueries                 endpoint.Endpoint
	SubmitDistributedQueryResults         endpoint.Endpoint
	SubmitLogs                            endpoint.Endpoint
	CreateLabel                           endpoint.Endpoint
	ModifyLabel                           endpoint.Endpoint
	GetLabel                              endpoint.Endpoint
	ListLabels                            endpoint.Endpoint
	ListHostsInLabel                      endpoint.Endpoint
	DeleteLabel                           endpoint.Endpoint
	DeleteLabelByID                       endpoint.Endpoint
	ApplyLabelSpecs                       endpoint.Endpoint
	GetLabelSpecs                         endpoint.Endpoint
	GetLabelSpec                          endpoint.Endpoint
	GetHost                               endpoint.Endpoint
	HostByIdentifier                      endpoint.Endpoint
	DeleteHost                            endpoint.Endpoint
	ListHosts                             endpoint.Endpoint
	GetHostSummary                        endpoint.Endpoint
	SearchTargets                         endpoint.Endpoint
	ApplyOsqueryOptionsSpec               endpoint.Endpoint
	GetOsqueryOptionsSpec                 endpoint.Endpoint
	GetCertificate                        endpoint.Endpoint
	ChangeEmail                           endpoint.Endpoint
	InitiateSSO                           endpoint.Endpoint
	CallbackSSO                           endpoint.Endpoint
	SSOSettings                           endpoint.Endpoint
	StatusResultStore                     endpoint.Endpoint
	StatusLiveQuery                       endpoint.Endpoint
}

KolideEndpoints is a collection of RPC endpoints implemented by the Kolide API.

func MakeKolideServerEndpoints

func MakeKolideServerEndpoints(svc kolide.Service, jwtKey, urlPrefix string) KolideEndpoints

MakeKolideServerEndpoints creates the Kolide API endpoints.

type LiveQueryResultsHandler

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

LiveQueryResultsHandler provides access to all of the information about an incoming stream of live query results.

func NewLiveQueryResultsHandler

func NewLiveQueryResultsHandler() *LiveQueryResultsHandler

func (*LiveQueryResultsHandler) Errors

func (h *LiveQueryResultsHandler) Errors() <-chan error

Errors returns a read channel that includes any errors returned by the server or receiving the results.

func (*LiveQueryResultsHandler) Results

Results returns a read channel including any received results

func (*LiveQueryResultsHandler) Status

func (h *LiveQueryResultsHandler) Status() *campaignStatus

func (*LiveQueryResultsHandler) Totals

func (h *LiveQueryResultsHandler) Totals() *targetTotals

Totals returns the current metadata of hosts targeted by the query

type NotFoundErr

type NotFoundErr interface {
	NotFound() bool
	Error() string
}

type NotSetupErr

type NotSetupErr interface {
	NotSetup() bool
	Error() string
}

type SetupAlreadyErr

type SetupAlreadyErr interface {
	SetupAlready() bool
	Error() string
}

Source Files

Jump to

Keyboard shortcuts

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