client

package
v0.0.0-...-fd09bc4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2016 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientPassphrase

func ClientPassphrase(s string)

Set the GPG passphrase to be used by the client for secret key operations.

func FindHomedir

func FindHomedir() string

func MakeConfiguration

func MakeConfiguration(file string) (err error)

MakeConfiguration generates a new configuration file for the current user

func PrintCommandResults

func PrintCommandResults(cmd mig.Command, onlyFound, showAgent bool) (err error)

func PrintMap

func PrintMap(locs []CommandLocation, title string) (err error)

func ValueToAction

func ValueToAction(v interface{}) (a mig.Action, err error)

func ValueToAgent

func ValueToAgent(v interface{}) (agt mig.Agent, err error)

func ValueToCommand

func ValueToCommand(v interface{}) (cmd mig.Command, err error)

func ValueToInvestigator

func ValueToInvestigator(v interface{}) (inv mig.Investigator, err error)

func ValueToLoaderEntry

func ValueToLoaderEntry(v interface{}) (l mig.LoaderEntry, err error)

func ValueToManifestRecord

func ValueToManifestRecord(v interface{}) (m mig.ManifestRecord, err error)

Types

type ApiConf

type ApiConf struct {
	URL            string
	SkipVerifyCert bool
}

type Client

type Client struct {
	API     *http.Client
	Token   string
	Conf    Configuration
	Version string
	// contains filtered or unexported fields
}

A Client provides all the needed functionalities to interact with the MIG API. It should be initialized with a proper configuration file.

func NewClient

func NewClient(conf Configuration, version string) (cli Client, err error)

NewClient initiates a new instance of a Client

func (Client) CompressAction

func (cli Client) CompressAction(a mig.Action) (comp_action mig.Action, err error)

CompressAction takens a MIG action, and applies compression to any operations within the action for which compression is requested.

This function should be called on the action prior to signing it for submission to the API.

func (*Client) DisableDebug

func (cli *Client) DisableDebug()

DisableDebug() disables the printing of debug messages to stdout

func (Client) Do

func (cli Client) Do(r *http.Request) (resp *http.Response, err error)

Do is a thin wrapper around http.Client.Do() that inserts an authentication header to the outgoing request

func (*Client) EnableDebug

func (cli *Client) EnableDebug()

EnableDebug() prints debug messages to stdout

func (Client) EvaluateAgentTarget

func (cli Client) EvaluateAgentTarget(target string) (agents []mig.Agent, err error)

EvaluateAgentTarget runs a search against the api to find all agents that match an action target string

func (Client) FetchActionResults

func (cli Client) FetchActionResults(a mig.Action) (ret []mig.Command, err error)

FetchActionResults retrieves mig command results associated with a particular action. This function differs from PrintActionResults in that it returns a slice of mig.Command structs, rather then printing results to stdout.

XXX Note in the future it may be worth refactoring the action print functions to make use of this, but it would require additional work.

func (Client) FollowAction

func (cli Client) FollowAction(a mig.Action, total int) (err error)

FollowAction continuously loops over an action and prints its completion status in os.Stderr. when the action reaches its expiration date, FollowAction prints its final status and returns.

func (Client) GetAPIResource

func (cli Client) GetAPIResource(target string) (resource *cljs.Resource, err error)

GetAPIResource retrieves a cljs resource from a target endpoint. The target must be the relative to the API URL passed in the configuration. For example, if the API URL is `http://localhost:12345/api/v1/` then target could only be set to `dashboard` to retrieve `http://localhost:12345/api/v1/dashboard`

func (Client) GetAction

func (cli Client) GetAction(aid float64) (a mig.Action, links []cljs.Link, err error)

GetAction retrieves a MIG Action from the API using its Action ID

func (Client) GetAgent

func (cli Client) GetAgent(agtid float64) (agt mig.Agent, err error)

func (Client) GetCommand

func (cli Client) GetCommand(cmdid float64) (cmd mig.Command, err error)

func (Client) GetInvestigator

func (cli Client) GetInvestigator(iid float64) (inv mig.Investigator, err error)

func (Client) GetLoaderEntry

func (cli Client) GetLoaderEntry(lid float64) (le mig.LoaderEntry, err error)

GetLoaderEntry retrieves a MIG loader entry from the API using the record ID

func (Client) GetManifestLoaders

func (cli Client) GetManifestLoaders(mid float64) (ldrs []mig.LoaderEntry, err error)

Retrieve list of known loader entries that will match manifest mid

func (Client) GetManifestRecord

func (cli Client) GetManifestRecord(mid float64) (mr mig.ManifestRecord, err error)

GetManifestRecord retrieves a MIG manifest record from the API using the record ID

func (Client) LoaderEntryExpect

func (cli Client) LoaderEntryExpect(le mig.LoaderEntry, eval string) (err error)

Change the expect fields of an existing loader entry

func (Client) LoaderEntryKey

func (cli Client) LoaderEntryKey(le mig.LoaderEntry, key string) (err error)

Change the key on an existing loader entry

func (Client) LoaderEntryStatus

func (cli Client) LoaderEntryStatus(le mig.LoaderEntry, status bool) (err error)

Change the status of an existing loader entry

func (Client) MakeSignedToken

func (cli Client) MakeSignedToken() (token string, err error)

MakeSignedToken encrypts a timestamp and a random number with the users GPG key to use as an auth token with the API

func (Client) ManifestRecordStatus

func (cli Client) ManifestRecordStatus(mr mig.ManifestRecord, status string) (err error)

Change the status of an existing manifest record

func (Client) PostAction

func (cli Client) PostAction(a mig.Action) (a2 mig.Action, err error)

PostAction submits a MIG Action to the API and returns the reflected action with API ID

func (Client) PostInvestigator

func (cli Client) PostInvestigator(name string, pubkey []byte, pset mig.InvestigatorPerms) (inv mig.Investigator, err error)

PostInvestigator creates an Investigator and returns the reflected investigator

func (Client) PostInvestigatorPerms

func (cli Client) PostInvestigatorPerms(iid float64, perm mig.InvestigatorPerms) (err error)

PostInvestigatorPerms sets permission on an investigator

func (Client) PostInvestigatorStatus

func (cli Client) PostInvestigatorStatus(iid float64, newstatus string) (err error)

PostInvestigatorStatus updates the status of an Investigator

func (Client) PostManifestSignature

func (cli Client) PostManifestSignature(mr mig.ManifestRecord, sig string) (err error)

Add a new signature to an existing manifest known to the API

func (Client) PostNewLoader

func (cli Client) PostNewLoader(le mig.LoaderEntry) (err error)

Post a new loader entry for storage through the API

func (Client) PostNewManifest

func (cli Client) PostNewManifest(mr mig.ManifestRecord) (err error)

Post a new manifest record for storage through the API

func (Client) PrintActionResults

func (cli Client) PrintActionResults(a mig.Action, show, render string) (err error)

func (Client) ResolveTargetMacro

func (cli Client) ResolveTargetMacro(target string) string

Resolves target macros; clients should pass the action target string here, and this function will return the resolved target if it is a valid macro, otherwise it just returns the passed target string

func (Client) SignAction

func (cli Client) SignAction(a mig.Action) (signed_action mig.Action, err error)

SignAction takes a MIG Action, signs it with the key identified in the configuration and returns the signed action

func (Client) SignManifest

func (cli Client) SignManifest(m mig.ManifestRecord) (ret string, err error)

SignManifest takes a MIG manifest record, signs it with the key identified in the configuration and returns the signature

type CommandLocation

type CommandLocation struct {
	Endpoint      string   `json:"endpoint"`
	CommandID     float64  `json:"commandid"`
	ActionID      float64  `json:"actionid"`
	FoundAnything bool     `json:"foundanything"`
	ConnectionsTo []string `json:"connections_to"`
	Latitude      float64  `json:"latitude"`
	Longitude     float64  `json:"longitude"`
	City          string   `json:"city"`
	Country       string   `json:"country"`
}

func ValueToLocation

func ValueToLocation(v interface{}) (cl CommandLocation, err error)

type Configuration

type Configuration struct {
	API     ApiConf    // location of the MIG API
	Homedir string     // location of the user's home directory
	GPG     GpgConf    // location of the user's secring
	Targets TargetConf // Target macro specification
}

Configuration stores the live configuration and global parameters of a client

func ReadConfiguration

func ReadConfiguration(file string) (conf Configuration, err error)

ReadConfiguration loads a client configuration from a local configuration file and verifies that GnuPG's secring is available

func ReadEnvConfiguration

func ReadEnvConfiguration(inconf Configuration) (conf Configuration, err error)

Read any possible configuration values from the environment; currently we only load a passphrase here if provided, but conf is passed/returned for any future requirements to override file based configuration using environment options.

type GpgConf

type GpgConf struct {
	Home      string
	KeyID     string
	Keyserver string
}

type TargetConf

type TargetConf struct {
	Macro []string
	// contains filtered or unexported fields
}

Directories

Path Synopsis
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.

Jump to

Keyboard shortcuts

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