definition

package
v0.0.0-...-a91c65e Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package definition maintains different datatypes used as input and their helper functions. Examples are service definitions, hosts or rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapServices

func MapServices(results ResultHosts, services ServiceDefs, rules []RulesDef)

map serviceIds to the scan results

Types

type HostDef

type HostDef struct {
	Address     string   `json:"address"`     // Adress, hostname or subnet in CIDR notation
	Description string   `json:"description"` // Short text description of the hosts purpose
	Tags        []string `json:"tags"`        // Tags for referencing a service
}

HostDef of the inventory

type HostDefs

type HostDefs []HostDef

Collection of host definitions from json file

func (*HostDefs) Find

func (defs *HostDefs) Find(host string) (HostDef, error)

Find returns a host definition by name or an error

func (*HostDefs) Init

func (defs *HostDefs) Init(hostsPath string) error

Init loads the HostDefs form a json file

type PortDef

type PortDef struct {
	Port        int      `json:"port"` // Port used by the service
	Protocol    string   `json:"protocol"`
	Description string   `json:"description"` // Short text description what is handled at the specific port
	Uri         string   `json:"uri"`         // Optional URI for reaching the service at the given port
	Rules       []string `json:"rules"`       // Rules which should be fulfilled by the service
	Hosts       []string `json:"hosts"`       // Hosts where the service is deployed. tag:tagvalue can also be used
}

PortDef for a service

type RuleDef

type RuleDef struct {
	Name     string `json:"name"`     // HTTP header with given name must exist
	Contains string `json:"contains"` // Optional, HTTP header must contain given value
}

RuleDef which must be matched by a service

type Rules

type Rules []RulesDef

Collection of rules definitions from json file

func (*Rules) Check

func (rules *Rules) Check(port PortDef, portResult *Port, service ServiceDef, ip string)

Check all rules against a specified host and port

func (*Rules) Init

func (rules *Rules) Init(rulesFile string) error

Init loads the rule definitions form a json file

type RulesDef

type RulesDef struct {
	Name            string    `json:"name"`             // Identifier of the rule
	Type_           string    `json:"type"`             // Type, currently 'http' is the only supported type
	FollowRedirects bool      `json:"follow-redirects"` // Type, currently 'http' is the only supported type
	Status          int       `json:"status"`           // Optional, expected http status
	Rules           []RuleDef `json:"rules"`            // Optional, Rules which must match
}

RulesDef can be referenced as one of the desired matching rules within a PortDef of a service

type ServiceDef

type ServiceDef struct {
	Id          string    `json:"id"`          // Identifier
	Description string    `json:"description"` //Short text description of the services purpose
	Ports       []PortDef `json:"ports"`       // Port definitions of the service
}

ServiceDef of a service

func (*ServiceDef) Print

func (service *ServiceDef) Print()

Print in a logging friendly way

type ServiceDefs

type ServiceDefs []ServiceDef

Collection of service definitions from json file

func (*ServiceDefs) Find

func (defs *ServiceDefs) Find(port int, host Host) (ServiceDef, error)

Find returns a service definition for a given host and port or an error

func (*ServiceDefs) FindById

func (defs *ServiceDefs) FindById(id string) (ServiceDef, error)

FindById returns the given service definition or an error

func (*ServiceDefs) Init

func (defs *ServiceDefs) Init(servicesPath string) error

Init loads the ServiceDefs form a json file

func (*ServiceDefs) Remove

func (defs *ServiceDefs) Remove(service ServiceDef) ServiceDefs

Return service definitions without the given service

Jump to

Keyboard shortcuts

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