client

package
v0.0.0-...-c3bd1f8 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2015 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Overview

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Contributor: Julien Vehent jvehent@mozilla.com [:ulfr]

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Contributor: Julien Vehent jvehent@mozilla.com [:ulfr]

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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)

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) 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) FollowAction

func (cli Client) FollowAction(a mig.Action) (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) 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) 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) (inv mig.Investigator, err error)

PostInvestigator creates an Investigator and returns the reflected investigator

func (Client) PostInvestigatorStatus

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

PostInvestigatorStatus updates the status of an Investigator

func (Client) PrintActionResults

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

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

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
}

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

type GpgConf

type GpgConf struct {
	Home      string
	KeyID     string
	Keyserver string
}

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