types

package
v0.0.0-...-797ef38 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const AesIvSize = 16

Variables

This section is empty.

Functions

func DecryptCbc

func DecryptCbc(aes cipher.Block, encrypted []byte, iv []byte) (string, error)

func DecryptGcm

func DecryptGcm(aes cipher.Block, encrypted []byte, nonce []byte, tagSize int) (string, error)

func KeyFilePath

func KeyFilePath(keyType string) (string, error)

KeyFilePath return the path to the file where the relevant PGP key is keyType is either verify (public) or sign (private) PGP key

func ToJson

func ToJson(object interface{}) ([]byte, error)

ToJson convert the passed-in object to a JSON byte slice NOTE: json.Marshal is purposely not used as it will escape any < > characters

Types

type Admission

type Admission struct {
	HostUUID string   `json:"host_uuid"`
	OrgGroup string   `json:"org_group"`
	Org      string   `json:"org"`
	Area     string   `json:"area"`
	Location string   `json:"location"`
	Label    []string `json:"label"`
}

Admission an admission request

type AesCrypto

type AesCrypto struct {
	CipherMode CipherMode
	Padding    Padding
}

func (AesCrypto) Decrypt

func (c AesCrypto) Decrypt(cipherText string, key []byte) (string, error)

func (AesCrypto) Encrypt

func (c AesCrypto) Encrypt(plainText string, key []byte) (string, error)

func (AesCrypto) EncryptCbc

func (c AesCrypto) EncryptCbc(aes cipher.Block, plainText string) (string, error)

func (AesCrypto) EncryptGcm

func (c AesCrypto) EncryptGcm(aes cipher.Block, plainText string) (string, error)

func (AesCrypto) PackCipherData

func (c AesCrypto) PackCipherData(cipherText []byte, iv []byte, tagSize int) string

func (AesCrypto) UnpackCipherData

func (c AesCrypto) UnpackCipherData(data []byte) ([]byte, []byte, int)

type Area

type Area struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

Area host area within a Location

type CipherMode

type CipherMode int
const (
	CBC CipherMode = iota
	GCM
)

type Cmd

type Cmd struct {
	// the natural key uniquely identifying the command
	Key string `json:"key"`
	// description of the command
	Description string `json:"description"`
	// the package to use
	Package string `json:"package"`
	// the function in the package to call
	Function string `json:"function"`
	// the function input information
	Input *data.Input `json:"input"`
	// the package registry user
	User string `json:"user"`
	// the package registry password
	Pwd string `json:"pwd"`
	// enables verbose output
	Verbose bool `json:"verbose"`
	// run command in runtime
	Containerised bool `json:"containerised"`
}

Cmd command information for remote host execution

type CmdInfo

type CmdInfo struct {
	JobId         int64       `json:"job_id"`
	Package       string      `json:"package"`
	Function      string      `json:"function"`
	User          string      `json:"user"`
	Pwd           string      `json:"pwd"`
	Verbose       bool        `json:"verbose"`
	Containerised bool        `json:"containerised"`
	Input         *data.Input `json:"input,omitempty"`
}

CmdInfo all the information required by pilot to execute a command

func (*CmdInfo) Env

func (c *CmdInfo) Env() []string

func (*CmdInfo) Envar

func (c *CmdInfo) Envar() *merge.Envar

func (*CmdInfo) PrintEnv

func (c *CmdInfo) PrintEnv() string

func (*CmdInfo) Value

func (c *CmdInfo) Value() string

type Cve

type Cve struct {
	Id               string
	Family           string
	Platform         string
	Summary          string
	AffectedPackages []models.PackageFixStatus
	CVSSScore        float64
	CVSSType         string
	CVSSVector       string
	CVSSSeverity     string
	Mitigations      []string
	PrimarySrc       []string
	PatchURLs        []string
	CPE              []string
	Confidence       []string
	References       []models.References
}

func (*Cve) Fixed

func (c *Cve) Fixed() bool

type CvePackage

type CvePackage struct {
	HostUUID    string
	CveID       string
	PackageName string
	FixedIn     string
	CvssScore   float64
}

type CveReport

type CveReport struct {
	Cves []*Cve
}

func NewCveReport

func NewCveReport(file []byte) (*CveReport, error)

func (*CveReport) Critical

func (r *CveReport) Critical() int

func (*CveReport) High

func (r *CveReport) High() int

func (*CveReport) Low

func (r *CveReport) Low() int

func (*CveReport) Medium

func (r *CveReport) Medium() int

type CveRequest

type CveRequest struct {
	HostUUID string `json:"host_uuid"`
	Report   []byte `json:"report"`
}

func (*CveRequest) Bytes

func (r *CveRequest) Bytes() (*[]byte, error)

func (*CveRequest) Reader

func (r *CveRequest) Reader() (*bytes.Reader, error)

type Dictionary

type Dictionary struct {
	// Key a natural key used to uniquely identify this dictionary for the purpose of idempotent opeartions
	Key string `json:"key" yaml:"key"`
	// Name a friendly name for the dictionary
	Name string `json:"name" yaml:"name"`
	// Description describe the purpose / content of the dictionary
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Values a map containing key/value pairs that are the content held by the dictionary
	Values map[string]interface{} `json:"values,omitempty" yaml:"values,omitempty"`
	// Tags a list of string based tags used for categorising the dictionary
	Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
}

Dictionary a key value pair list with name and description

type Event

type Event struct {
	EventID           string    `json:"event_id,omitempty" yaml:"event_id,omitempty" bson:"event_id,omitempty"`
	Client            string    `json:"client,omitempty" yaml:"client,omitempty" bson:"client,omitempty"`
	Hostname          string    `json:"hostname,omitempty" yaml:"hostname,omitempty" bson:"hostname,omitempty"`
	HostUUID          string    `json:"host_uuid,omitempty" yaml:"host_uuid,omitempty" bson:"host_uuid,omitempty"`
	MachineId         string    `json:"machine_id" yaml:"machine_id" bson:"machine_id"`
	HostAddress       string    `json:"host_address,omitempty" yaml:"host_address,omitempty" bson:"host_address,omitempty"`
	Organisation      string    `json:"org,omitempty" yaml:"org,omitempty" bson:"org,omitempty"`
	OrganisationGroup string    `json:"org_group,omitempty" yaml:"org_group,omitempty" bson:"org_group,omitempty"`
	Area              string    `json:"area,omitempty" yaml:"area,omitempty" bson:"area,omitempty"`
	Location          string    `json:"location,omitempty" yaml:"location,omitempty" bson:"location,omitempty"`
	Facility          int       `json:"facility,omitempty" yaml:"facility,omitempty" bson:"facility,omitempty"`
	Priority          int       `json:"priority,omitempty" yaml:"priority,omitempty" bson:"priority,omitempty"`
	Severity          int       `json:"severity,omitempty" yaml:"severity,omitempty" bson:"severity,omitempty"`
	Time              time.Time `json:"time,omitempty" yaml:"time,omitempty" bson:"time,omitempty"`
	TLSPeer           string    `json:"tls_peer,omitempty" yaml:"tls_peer,omitempty" bson:"tls_peer,omitempty"`
	BootTime          time.Time `json:"boot_time,omitempty" yaml:"boot_time,omitempty" bson:"boot_time,omitempty"`
	Content           string    `json:"content,omitempty" yaml:"content,omitempty" bson:"content,omitempty"`
	Tag               string    `json:"tag,omitempty" yaml:"tag,omitempty" bson:"tag,omitempty"`
	MacAddress        []string  `json:"mac_address,omitempty" yaml:"mac_address,omitempty" bson:"mac_address,omitempty"`
	HostLabel         []string  `json:"host_label,omitempty" yaml:"host_label,omitempty" bson:"host_label,omitempty"`
	// contains filtered or unexported fields
}

Event a pilot event to be sent to piloctl service

func NewEvent

func NewEvent(logPart format.LogParts, info HostInfo) (*Event, error)

NewEvent create a new serializable event from a syslog entry in RFC 3164

func (*Event) Save

func (e *Event) Save(path string) error

Save the event to the file system path: is the folder where events will be saved

type EventReceiver

type EventReceiver struct {
	Name string `json:"name,omitempty"`
	URI  string `json:"uri"`
	// optional credentials if authentication is required
	User string `json:"user,omitempty"`
	Pwd  string `json:"pwd,omitempty"`
}

type EventReceivers

type EventReceivers struct {
	EventReceivers []EventReceiver `json:"event_receivers"`
}

func NewEventPubConf

func NewEventPubConf() *EventReceivers

type Events

type Events struct {
	Events []Event `json:"events"`
}

func (*Events) Bytes

func (r *Events) Bytes() (*[]byte, error)

func (*Events) Reader

func (r *Events) Reader() (*bytes.Reader, error)

type Host

type Host struct {
	Id             int64    `json:"id"`
	HostUUID       string   `json:"host_uuid"`
	HostMacAddress string   `json:"host_mac_address"`
	OrgGroup       string   `json:"org_group"`
	Org            string   `json:"org"`
	Area           string   `json:"area"`
	Location       string   `json:"location"`
	Connected      bool     `json:"connected"`
	LastSeen       int64    `json:"last_seen"`
	Since          int      `json:"since"`
	SinceType      string   `json:"since_type"`
	Label          []string `json:"label"`
	Critical       int      `json:"critical"`
	High           int      `json:"high"`
	Medium         int      `json:"medium"`
	Low            int      `json:"low"`
}

Host monitoring information

type HostInfo

type HostInfo struct {
	HostUUID        string
	MachineId       string
	HostName        string
	OS              string
	Platform        string
	PlatformFamily  string
	PlatformVersion string
	Virtual         bool
	TotalMemory     float64
	CPUs            int
	HostIP          string
	BootTime        time.Time
	MacAddress      []string
	PrimaryMAC      string
	HardwareId      string
}

HostInfo abstracts host information

func NewHostInfo

func NewHostInfo() (*HostInfo, error)

func (*HostInfo) String

func (h *HostInfo) String() string

type Job

type Job struct {
	Id         int64    `json:"id"`
	HostUUID   string   `json:"host_uuid"`
	JobBatchId int64    `json:"job_batch_id"`
	FxKey      string   `json:"fx_key"`
	FxVersion  int64    `json:"fx_version"`
	Created    string   `json:"created"`
	Started    string   `json:"started"`
	Completed  string   `json:"completed"`
	Log        string   `json:"log"`
	Error      bool     `json:"error"`
	OrgGroup   string   `json:"org_group"`
	Org        string   `json:"org"`
	Area       string   `json:"area"`
	Location   string   `json:"location"`
	Tag        []string `json:"tag"`
}

Job a representation of a job in the database

type JobBatch

type JobBatch struct {
	// the id of the job batch
	BatchId int64 `json:"batch_id"`
	// the name of the batch (not unique, a user-friendly name)
	Name string `json:"name"`
	// any relevant notes for the batch (not mandatory)
	Notes string `json:"notes,omitempty"`
	// creation time
	Created time.Time `json:"created"`
	// one or more search labels
	Label []string `json:"label,omitempty"`
	// owner
	Owner string `json:"owner"`
	// jobs
	Jobs int `json:"jobs"`
}

JobBatch a representation of a batch in the database

type JobBatchInfo

type JobBatchInfo struct {
	// the name of the batch (not unique, a user-friendly name)
	Name string `json:"name"`
	// any relevant notes for the batch (not mandatory)
	Notes string `json:"notes,omitempty"`
	// one or more search labels
	Label []string `json:"label,omitempty"`
	// the universally unique host identifier created by pilot
	HostUUID []string `json:"host_uuid"`
	// the unique key of the function to run
	FxKey string `json:"fx_key"`
	// the version of the function to run
	FxVersion int64 `json:"fx_version"`
}

JobBatchInfo information required to create a new job batch

type JobResult

type JobResult struct {
	// the unique job id
	JobId int64
	// indicates of the job was successful
	Success bool
	// the execution log for the job
	Log string
	// the error if any
	Err string
	// the completion time
	Time time.Time
}

JobResult the result of the execution of a job note: ensure it is aligned with the same struct in piloth

type Location

type Location struct {
	Key  string `json:"key"`
	Name string `json:"name"`
}

Location host location

type Org

type Org struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

Org host organisation

type PGP

type PGP struct {
	// contains filtered or unexported fields
}

PGP entity for signing, verification, encryption and decryption

func LoadPGP

func LoadPGP(filename, passphrase string) (*PGP, error)

LoadPGP load a PGP entity from file

func LoadPGPBytes

func LoadPGPBytes(key []byte) (*PGP, error)

func (*PGP) Decrypt

func (p *PGP) Decrypt(encrypted []byte) ([]byte, error)

Decrypt decrypts the specified message

func (*PGP) Encrypt

func (p *PGP) Encrypt(message []byte) ([]byte, error)

Encrypt encrypts the specified message

func (*PGP) HasPrivate

func (p *PGP) HasPrivate() bool

HasPrivate check if the PGP entity has a private key, if not an error is returned

func (*PGP) Sign

func (p *PGP) Sign(message []byte) ([]byte, error)

Sign signs the specified message (requires loading a private key)

func (*PGP) Verify

func (p *PGP) Verify(message []byte, signature []byte) error

Verify verifies the message using a specified signature (requires loading a public key)

type PackageInfo

type PackageInfo struct {
	Name string    `json:"name"`
	Tags []TagInfo `json:"tags,omitempty"`
}

PackageInfo describes a package and all its tags

type Padding

type Padding int
const (
	NoPadding Padding = iota
	PKCS7
)

type PingRequest

type PingRequest struct {
	Result *JobResult `json:"result,omitempty"`
}

func (*PingRequest) Bytes

func (r *PingRequest) Bytes() (*[]byte, error)

func (*PingRequest) Reader

func (r *PingRequest) Reader() (*bytes.Reader, error)

type PingResponse

type PingResponse struct {
	// the envelope signature
	Signature string `json:"signature"`
	// the signed content sent to pilot
	Envelope PingResponseEnvelope `json:"envelope"`
}

PingResponse a command for execution with a job reference

func NewPingResponse

func NewPingResponse(cmdInfo CmdInfo, pingInterval time.Duration) (*PingResponse, error)

NewPingResponse creates a new ping response

type PingResponseEnvelope

type PingResponseEnvelope struct {
	// the information about the command to execute
	Command CmdInfo `json:"value"`
	// the ping interval
	Interval time.Duration `json:"interval"`
}

PingResponseEnvelope contains the signed content sent to pilot

type Registration

type Registration struct {
	MacAddress string   `json:"mac_address"`
	OrgGroup   string   `json:"org_group"`
	Org        string   `json:"org"`
	Area       string   `json:"area"`
	Location   string   `json:"location"`
	Label      []string `json:"label"`
}

type RegistrationRequest

type RegistrationRequest struct {
	Hostname    string   `json:"hostname"`
	HostIP      string   `json:"host_ip"`
	MachineId   string   `json:"machine_id"`
	OS          string   `json:"os"`
	Platform    string   `json:"platform"`
	Virtual     bool     `json:"virtual"`
	TotalMemory float64  `json:"total_memory"`
	CPUs        int      `json:"cpus"`
	MacAddress  []string `json:"mac_address"`
}

RegistrationRequest information sent by pilot upon host registration

func (*RegistrationRequest) Bytes

func (r *RegistrationRequest) Bytes() (*[]byte, error)

Bytes Get a []byte representing the Serializable

func (*RegistrationRequest) Reader

func (r *RegistrationRequest) Reader() (*bytes.Reader, error)

Reader Get a JSON bytes reader for the Serializable

type RegistrationResponse

type RegistrationResponse struct {
	// the status of the registration - I: created, U: updated, N: already exist
	Operation string `json:"operation"`
}

RegistrationResponse data returned to pilot upon registration

type TagInfo

type TagInfo struct {
	Id      string `json:"id"`
	Name    string `json:"name"`
	Ref     string `json:"ref"`
	Created string `json:"created"`
	Type    string `json:"type"`
	Size    string `json:"size"`
}

Jump to

Keyboard shortcuts

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