attack

package
v0.0.0-...-6a3c6e2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2019 License: Apache-2.0 Imports: 4 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deregister

func Deregister(id string) error

Deregister deregisters a attack creator on base registry.

func Exists

func Exists(id string) bool

Exists checks a attack creator exists on the base registry.

func Register

func Register(id string, c Creater) error

Register registers a new attack creator on base registry.

Types

type Attacker

type Attacker interface {

	// Apply applies an attack or fault to the system
	Apply(ctx context.Context) error

	// Revert reverts an attack or fault from the system
	Revert() error
}

Attacker implements the lowest level of error applied to a system.

func New

func New(id string, opts Opts) (Attacker, error)

New is the factory method of attackers on the base registry.

type Creater

type Creater interface {
	Create(opts Opts) (Attacker, error)
}

Creater should be implement by any attacker that wants to be automatically created by the global registry of attacks.

type CreatorFunc

type CreatorFunc func(o Opts) (Attacker, error)

CreatorFunc implements Creater interface as a handy way of creating creaters quickly

func (CreatorFunc) Create

func (c CreatorFunc) Create(opts Opts) (Attacker, error)

Create implements Creater.

type Opts

type Opts map[string]interface{}

Opts are the option map of an attack.

type Registry

type Registry interface {
	Register(id string, c Creater) error
	Deregister(id string) error
	Exists(id string) bool
	New(id string, opts Opts) (Attacker, error)
}

Registry is an interface that needs to be implemented by any attack registry.

func BaseReg

func BaseReg() Registry

BaseReg returns global application attack creator registry.

type SimpleRegistry

type SimpleRegistry map[string]Creater

SimpleRegistry is basic registry of attackers.

func NewSimpleRegistry

func NewSimpleRegistry() SimpleRegistry

NewSimpleRegistry returns a basic registerer.

func (SimpleRegistry) Deregister

func (r SimpleRegistry) Deregister(id string) error

Deregister deregisters a attack creator.

func (SimpleRegistry) Exists

func (r SimpleRegistry) Exists(id string) bool

Exists returns true if the creator is registered for a given ID, false instead.

func (SimpleRegistry) New

func (r SimpleRegistry) New(id string, opts Opts) (Attacker, error)

New is the factory of the attacks based on IDs and options.

func (SimpleRegistry) Register

func (r SimpleRegistry) Register(id string, c Creater) error

Register registers a attack creator.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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