modules

package
v0.0.0-...-2c15bd8 Latest Latest
Warning

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

Go to latest
Published: May 9, 2016 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

This package implements interfaces to write modules for MIG.

For a guide on how to write modules, head over to http://mig.mozilla.org/doc/modules.rst.html

Index

Constants

This section is empty.

Variables

View Source
var Available = make(map[string]Moduler)

The set of registered modules

Functions

func MakeMessage

func MakeMessage(class MessageClass, params interface{}, comp bool) (rawMsg []byte, err error)

MakeMessage creates a new modules.Message with a given class and parameters and return the byte slice of the json marshalled message

func ReadInputParameters

func ReadInputParameters(r io.Reader, p interface{}) (err error)

ReadInputParameters reads the first line from stdin and expects to find a modules.Message of class `parameters`. This function uses ReadInput and will block waiting for data on stdin

func Register

func Register(name string, mod Moduler)

Register a new module as available

func WatchForStop

func WatchForStop(r io.Reader, stopChan *chan bool) error

WatchForStop continuously reads stdin for a stop message. When one is received, `true` is sent into the stop channel.

Types

type HasParamsCreator

type HasParamsCreator interface {
	ParamsCreator() (interface{}, error)
}

HasParamsCreator implements a function that creates module parameters

type HasParamsParser

type HasParamsParser interface {
	ParamsParser([]string) (interface{}, error)
}

HasParamsParser implements a function that parses command line parameters

type HasResultsPrinter

type HasResultsPrinter interface {
	PrintResults(Result, bool) ([]string, error)
}

HasResultsPrinter implements functions used by module to print information

type Message

type Message struct {
	Class      MessageClass `json:"class"`                // represent the type of message being passed to the module
	Parameters interface{}  `json:"parameters,omitempty"` // for `parameters` class, this interface contains the module parameters
}

Message defines the input messages received by modules.

func ReadInput

func ReadInput(r io.Reader) (msg Message, err error)

ReadInput reads one line of input from stdin, unmarshal it into a modules.Message and returns the message to the caller

type MessageClass

type MessageClass string
const (
	MsgClassParameters MessageClass = "parameters"
	MsgClassStop       MessageClass = "stop"
)

type Moduler

type Moduler interface {
	NewRun() Runner
}

A mig module implements this interface

type Result

type Result struct {
	FoundAnything bool        `json:"foundanything"`
	Success       bool        `json:"success"`
	Elements      interface{} `json:"elements"`
	Statistics    interface{} `json:"statistics"`
	Errors        []string    `json:"errors"`
}

Result implement the base type for results returned by modules. All modules must return this type of result. The fields are:

  • FoundAnything: a boolean that must be set to true if the module ran a search that returned at least one positive result
  • Success: a boolean that must be set to true if the module ran without fatal errors. soft errors are reported in Errors
  • Elements: an undefined type that can be customized by the module to contain the detailled results
  • Statistics: an undefined type that can be customized by the module to contain some information about how it ran
  • Errors: an array of strings that contain non-fatal errors encountered by the module

func (Result) GetElements

func (r Result) GetElements(el interface{}) (err error)

GetElements reads the elements from a struct of results into the el interface

func (Result) GetStatistics

func (r Result) GetStatistics(stats interface{}) (err error)

GetStatistics reads the statistics from a struct of results into the stats interface

type Runner

type Runner interface {
	Run(io.Reader) string
	ValidateParameters() error
}

Runner provides the interface to an execution of a module

Directories

Path Synopsis
This is an example module.
This is an example module.
The file module provides functions to scan a file system.
The file module provides functions to scan a file system.
netstat is a module that retrieves network information about the endpoint, such as mac addresses, local and connected IPs, listening TCP and UDP sockets and peers
netstat is a module that retrieves network information about the endpoint, such as mac addresses, local and connected IPs, listening TCP and UDP sockets and peers
scribe module implementation for MIG.
scribe module implementation for MIG.
The upgrade module is used to download and install a new version of the mig-agent.
The upgrade module is used to download and install a new version of the mig-agent.

Jump to

Keyboard shortcuts

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