client

package
v0.0.0-...-1ab713d Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package client provides a GRR client object which handles associated API calls via an arbitrary transfer protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmailCCAddresses

func EmailCCAddresses(emailAddresses []string) func(args *aupb.ApiCreateClientApprovalArgs)

EmailCCAddresses is an optional argument that can be passed into CreateApproval to add email cc addresses for the operation. Example usage could look like this: CreateApproval(ctx, conn, EmailCCAddresses([]string{...})).

func KeepClientAlive

func KeepClientAlive() func(args *aupb.ApiCreateClientApprovalArgs)

KeepClientAlive is an optional argument that can be passed into CreateApproval to keep client alive. Example usage could look like this: CreateApproval(ctx, conn, KeepClientAlive())

func SearchClients

func SearchClients(ctx context.Context, conn Connector, query string, fn func(c *Client) error, options ...SearchClientsOption) error

SearchClients sends a request to GRR server to search for clients using given query and calls fn (a callback function) on each Client object. An optional argument can be passed (see function WithMaxCount).

func WithRunnerArgs

func WithRunnerArgs(flowRunnerArgs *flowpb.FlowRunnerArgs) func(args *afpb.ApiCreateFlowArgs)

WithRunnerArgs is an optional argument that can be passed into CreateFlow to define the runner arguments of new flow. Example usage could look like this: CreateFlow(ctx, conn, WithRunnerArgs(&flowpb.FlowRunnerArgs{...})).

Types

type Approval

type Approval struct {
	ID       string
	ClientID string
	Username string
	Data     *aupb.ApiClientApproval
	// contains filtered or unexported fields
}

Approval object is a helper object to send requests to GRR server via an arbitrary transfer protocol.

func (*Approval) Get

func (a *Approval) Get(ctx context.Context) error

Get sends a request to GRR server to get information for a client approval and fills it in Data field. If an error occurs, Data field will stay unchanged.

func (*Approval) Grant

func (a *Approval) Grant(ctx context.Context) error

Grant sends a request to GRR server to grand a client approval. If an error occurs, Data field will stay unchanged.

type Client

type Client struct {
	ID   string
	Data *acpb.ApiClient
	// contains filtered or unexported fields
}

Client object is a helper object to send requests to GRR server via an arbitrary transfer protocol.

func NewClient

func NewClient(id string, conn Connector) *Client

NewClient returns a new client ref with given id and connector.

func (*Client) AddLabels

func (c *Client) AddLabels(ctx context.Context, Labels []string) error

AddLabels sends a request to GRR server to add labels for the client.

func (*Client) Approval

func (c *Client) Approval(id string, username string) *Approval

Approval returns a Approval ref with given approval id, username and current client id.

func (*Client) CreateApproval

func (c *Client) CreateApproval(ctx context.Context, reason string, notifiedUsers []string, options ...func(args *aupb.ApiCreateClientApprovalArgs)) (*Approval, error)

CreateApproval sends a request to GRR server to create a new client approval with given reason and notify users. KeepClientAlive is set to false by default.

func (*Client) CreateFlow

func (c *Client) CreateFlow(ctx context.Context, name string, flowArgs proto.Message, options ...func(args *afpb.ApiCreateFlowArgs)) (*flow.Flow, error)

CreateFlow sends a request to GRR server to create a new flow with given name and arguments of the flow.

func (*Client) File

func (c *Client) File(path string) *vfs.File

File returns a file object with a given path on client's VFS.

func (*Client) Flow

func (c *Client) Flow(id string) *flow.Flow

Flow returns a new flow object with given flow ID and current client id and connector.

func (*Client) Get

func (c *Client) Get(ctx context.Context) error

Get sends a request to GRR server to get information for a client and fills it in Data field. If an error occurs, Data field will stay unchanged.

func (*Client) ListApprovals

func (c *Client) ListApprovals(ctx context.Context, state *aupb.ApiListClientApprovalsArgs_State, fn func(a *Approval) error) error

ListApprovals sends a request to GRR server to list all approvals of the client and calls fn (a callback function) on each Approval object.

func (*Client) ListFlows

func (c *Client) ListFlows(ctx context.Context, fn func(f *flow.Flow) error) error

ListFlows sends a request to GRR server to list flows on a given client, and calls fn (a callback function) on each Flow object.

func (*Client) RemoveLabels

func (c *Client) RemoveLabels(ctx context.Context, Labels []string) error

RemoveLabels sends a request to GRR server to remove labels from the client.

type Connector

type Connector interface {
	// Adds given list of labels to given clients.
	AddClientsLabels(ctx context.Context, args *acpb.ApiAddClientsLabelsArgs) error
	// Removes given labels from given clients.
	RemoveClientsLabels(ctx context.Context, args *acpb.ApiRemoveClientsLabelsArgs) error
	// Returns information for a client approval with a given reason.
	GetClientApproval(ctx context.Context, args *aupb.ApiGetClientApprovalArgs) (*aupb.ApiClientApproval, error)
	// GetUsername returns username of the current user.
	GetUsername(ctx context.Context) (string, error)
	// Lists all the client approvals.
	ListClientApprovals(ctx context.Context, args *aupb.ApiListClientApprovalsArgs, fn func(m *aupb.ApiClientApproval) error) error
	// List flows on a given client.
	ListFlows(ctx context.Context, args *afpb.ApiListFlowsArgs, fn func(m *afpb.ApiFlow) error) error
	// Grant client approval.
	GrantClientApproval(ctx context.Context, args *aupb.ApiGrantClientApprovalArgs) (*aupb.ApiClientApproval, error)
	// Create a new client approval.
	CreateClientApproval(ctx context.Context, args *aupb.ApiCreateClientApprovalArgs) (*aupb.ApiClientApproval, error)
	// Start a new flow on a given client.
	CreateFlow(ctx context.Context, args *afpb.ApiCreateFlowArgs) (*afpb.ApiFlow, error)
	// Get client with a given client id.
	GetClient(ctx context.Context, args *acpb.ApiGetClientArgs) (*acpb.ApiClient, error)
	// Search for clients using a search query
	SearchClients(ctx context.Context, args *acpb.ApiSearchClientsArgs, fn func(m *acpb.ApiClient) error) error

	flow.Connector
	vfs.Connector
}

Connector abstracts GRR communication protocols (i.e. HTTP, Stubby) and handles API calls related to clients.

type SearchClientsOption

type SearchClientsOption func(args *acpb.ApiSearchClientsArgs)

SearchClientsOption is a function signature for avoiding repetitive typing.

func WithMaxCount

func WithMaxCount(count int64) SearchClientsOption

WithMaxCount is an optional argument that can be passed into SearchClients to restrict the maximum number of clients returned from the response. Example usage could look like this: SearchClients(ctx, conn, WithMaxCount(1)).

Jump to

Keyboard shortcuts

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