collector

package
v0.0.0-...-9bd7aee Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthernetStr       = "Ethernet"
	EmergencyStr      = "Emergency"
	InfrastructureStr = "Infrastructure"
	EnvironmentStr    = "Environment"
	ApplicationStr    = "Application"
	EmptyStr          = "<Empty>"
)
View Source
const (
	ProtocolTCP  = "tcp"
	ProtocolUDP  = "udp"
	ProtocolICMP = "icmp"
	TCPFlagSYN   = 2
)

Variables

Functions

func DeleteResource

func DeleteResource(server ServerData, query string) error

func FixResourcesForJSON

func FixResourcesForJSON(res *ResourcesContainerModel)

func IsConnected

func IsConnected(got *ResourcesContainerModel, t1, t2 treeNode) bool

func IsVMConnected

func IsVMConnected(got *ResourcesContainerModel, uid1, uid2 string) bool

func PutResource

func PutResource[A json.Unmarshaler](server ServerData, query string, resource A) error

func TryUnmarshalError

func TryUnmarshalError(b []byte) ([]string, error)

func Unmarshal2Fields

func Unmarshal2Fields[fieldType1 any, fieldType2 any](
	b []byte,
	entry1 string, field1 *fieldType1,
	entry2 string, field2 *fieldType2,
) error

func UnmarshalBaseStructAnd1Field

func UnmarshalBaseStructAnd1Field[baseType any, fieldType1 any](
	b []byte, base *baseType,
	entry1 string, field1 *fieldType1,
) error

func UnmarshalBaseStructAnd2Fields

func UnmarshalBaseStructAnd2Fields[baseType any, fieldType1 any, fieldType2 any](
	b []byte, base *baseType,
	entry1 string, field1 *fieldType1,
	entry2 string, field2 *fieldType2,
) error

func UnmarshalBaseStructAnd4Fields

func UnmarshalBaseStructAnd4Fields[baseType any, fieldType1 any, fieldType2 any, fieldType3 any, fieldType4 any](
	b []byte, base *baseType,
	entry1 string, field1 *fieldType1,
	entry2 string, field2 *fieldType2,
	entry3 string, field3 *fieldType3,
	entry4 string, field4 *fieldType4,
) error

Types

type ALGTypeServiceEntry

type ALGTypeServiceEntry struct {
	nsx.ALGTypeServiceEntry
}

func (*ALGTypeServiceEntry) String

func (e *ALGTypeServiceEntry) String() string

func (*ALGTypeServiceEntry) ToConnection

func (e *ALGTypeServiceEntry) ToConnection() (*netset.TransportSet, error)

type Condition

type Condition struct {
	nsx.Condition
}

func (*Condition) String

func (e *Condition) String() string

type ConjunctionOperator

type ConjunctionOperator struct {
	nsx.ConjunctionOperator
}

func (*ConjunctionOperator) String

func (e *ConjunctionOperator) String() string

type DfwCategory

type DfwCategory int
const (
	EthernetCategory DfwCategory = iota
	EmergencyCategory
	InfrastructureCategory
	EnvCategory
	AppCategoty
	EmptyCategory
)

func MinCategory

func MinCategory() DfwCategory

func (DfwCategory) String

func (d DfwCategory) String() string

type Domain

type Domain struct {
	nsx.Domain
	Resources DomainResources `json:"resources"`
}

func (*Domain) UnmarshalJSON

func (domain *Domain) UnmarshalJSON(b []byte) error

type DomainResources

type DomainResources struct {
	SecurityPolicyList    []SecurityPolicy    `json:"security_policies"`
	GatewayPolicyList     []GatewayPolicy     `json:"gateway_policies"`
	RedirectionPolicyList []RedirectionPolicy `json:"redirection_policies"`
	GroupList             []Group             `json:"groups"`
}

func (*DomainResources) GetGroup

func (resources *DomainResources) GetGroup(query string) *Group

type EtherTypeServiceEntry

type EtherTypeServiceEntry struct {
	nsx.EtherTypeServiceEntry
}

func (*EtherTypeServiceEntry) String

func (e *EtherTypeServiceEntry) String() string

func (*EtherTypeServiceEntry) ToConnection

func (e *EtherTypeServiceEntry) ToConnection() (*netset.TransportSet, error)

type Expression

type Expression []ExpressionElement

func (*Expression) String

func (e *Expression) String() string

func (*Expression) UnmarshalJSON

func (e *Expression) UnmarshalJSON(b []byte) error

type ExpressionElement

type ExpressionElement interface {
	String() string
}

type ExternalIDExpression

type ExternalIDExpression struct {
	nsx.ExternalIDExpression
}

func (*ExternalIDExpression) String

func (e *ExternalIDExpression) String() string

type FirewallRule

type FirewallRule struct {
	nsx.FirewallRule
}

type GatewayPolicy

type GatewayPolicy struct {
	nsx.GatewayPolicy
	Rules []Rule `json:"rules,omitempty"`
}

/////////////////////////////////////////////////////////////////////////////////////

func (*GatewayPolicy) UnmarshalJSON

func (gatewayPolicy *GatewayPolicy) UnmarshalJSON(b []byte) error

type Group

type Group struct {
	nsx.Group
	VMMembers      []RealizedVirtualMachine  `json:"vm_members,omitempty"`
	VIFMembers     []VirtualNetworkInterface `json:"vif_members,omitempty"`
	AddressMembers []nsx.IPElement           `json:"ips_members,omitempty"`
	Expression     Expression                `json:"expression,omitempty"`
}

func (*Group) Description

func (group *Group) Description() string

func (*Group) Name

func (group *Group) Name() string

func (*Group) UnmarshalJSON

func (group *Group) UnmarshalJSON(b []byte) error

type ICMPTypeServiceEntry

type ICMPTypeServiceEntry struct {
	nsx.ICMPTypeServiceEntry
}

func (*ICMPTypeServiceEntry) String

func (e *ICMPTypeServiceEntry) String() string

func (*ICMPTypeServiceEntry) ToConnection

func (e *ICMPTypeServiceEntry) ToConnection() (*netset.TransportSet, error)

type IGMPTypeServiceEntry

type IGMPTypeServiceEntry struct {
	nsx.IGMPTypeServiceEntry
}

func (*IGMPTypeServiceEntry) String

func (e *IGMPTypeServiceEntry) String() string

func (*IGMPTypeServiceEntry) ToConnection

func (e *IGMPTypeServiceEntry) ToConnection() (*netset.TransportSet, error)

type IPAddressExpression

type IPAddressExpression struct {
	nsx.IPAddressExpression
}

func (*IPAddressExpression) String

func (e *IPAddressExpression) String() string

type IPProtocolServiceEntry

type IPProtocolServiceEntry struct {
	nsx.IPProtocolServiceEntry
}

/////////////////////////////////////////////////////////////////////////////////////

func (*IPProtocolServiceEntry) String

func (e *IPProtocolServiceEntry) String() string

func (*IPProtocolServiceEntry) ToConnection

func (e *IPProtocolServiceEntry) ToConnection() (*netset.TransportSet, error)

type IdentityGroupExpression

type IdentityGroupExpression struct {
	nsx.IdentityGroupExpression
}

func (*IdentityGroupExpression) String

func (e *IdentityGroupExpression) String() string

type L4PortSetServiceEntry

type L4PortSetServiceEntry struct {
	nsx.L4PortSetServiceEntry
}

func (*L4PortSetServiceEntry) String

func (e *L4PortSetServiceEntry) String() string

func (*L4PortSetServiceEntry) ToConnection

func (e *L4PortSetServiceEntry) ToConnection() (*netset.TransportSet, error)

type MACAddressExpression

type MACAddressExpression struct {
	nsx.MACAddressExpression
}

func (*MACAddressExpression) String

func (e *MACAddressExpression) String() string

type NestedExpression

type NestedExpression struct {
	nsx.NestedExpression
}

func (*NestedExpression) String

func (e *NestedExpression) String() string

type NestedServiceServiceEntry

type NestedServiceServiceEntry struct {
	nsx.NestedServiceServiceEntry
}

func (*NestedServiceServiceEntry) String

func (e *NestedServiceServiceEntry) String() string

func (*NestedServiceServiceEntry) ToConnection

func (e *NestedServiceServiceEntry) ToConnection() (*netset.TransportSet, error)

type PathExpression

type PathExpression struct {
	nsx.PathExpression
}

func (*PathExpression) String

func (e *PathExpression) String() string

type PolicyNat

type PolicyNat struct {
	nsx.PolicyNat
	Rules []PolicyNatRule `json:"rules,omitempty"`
}

func (*PolicyNat) UnmarshalJSON

func (policyNat *PolicyNat) UnmarshalJSON(b []byte) error

type PolicyNatRule

type PolicyNatRule struct {
	nsx.PolicyNatRule
}

type PolicyTraceflowObservationDelivered

type PolicyTraceflowObservationDelivered struct {
	nsx.PolicyTraceflowObservationDelivered
}

type PolicyTraceflowObservationDropped

type PolicyTraceflowObservationDropped struct {
	nsx.PolicyTraceflowObservationDropped
}

type PolicyTraceflowObservationDroppedLogical

type PolicyTraceflowObservationDroppedLogical struct {
	nsx.PolicyTraceflowObservationDroppedLogical
}

type PolicyTraceflowObservationForwardedLogical

type PolicyTraceflowObservationForwardedLogical struct {
	nsx.PolicyTraceflowObservationForwardedLogical
}

type PolicyTraceflowObservationReceivedLogical

type PolicyTraceflowObservationReceivedLogical struct {
	nsx.PolicyTraceflowObservationReceivedLogical
}

type PolicyTraceflowObservationRelayedLogical

type PolicyTraceflowObservationRelayedLogical struct {
	nsx.PolicyTraceflowObservationRelayedLogical
}

type RealizedVirtualMachine

type RealizedVirtualMachine struct {
	nsx.RealizedVirtualMachine
}

type RedirectionPolicy

type RedirectionPolicy struct {
	nsx.RedirectionPolicy
	RedirectionRules []RedirectionRule `json:"rules,omitempty"`
}

/////////////////////////////////////////////////////////////////////////////////////

func (*RedirectionPolicy) UnmarshalJSON

func (redirectionPolicy *RedirectionPolicy) UnmarshalJSON(b []byte) error

type RedirectionRule

type RedirectionRule struct {
	nsx.RedirectionRule
	ServiceEntries ServiceEntries `json:"service_entries,omitempty"`
}

func (*RedirectionRule) UnmarshalJSON

func (rule *RedirectionRule) UnmarshalJSON(b []byte) error

type ResourcesContainerModel

type ResourcesContainerModel struct {
	ServiceList                 []Service                 `json:"services"`
	VirtualMachineList          []VirtualMachine          `json:"virtual_machines"`
	VirtualNetworkInterfaceList []VirtualNetworkInterface `json:"virtual_network_interface"`
	SegmentList                 []Segment                 `json:"segments"`
	Tier0List                   []Tier0                   `json:"tier0"`
	Tier1List                   []Tier1                   `json:"tier1"`
	DomainList                  []Domain                  `json:"domains"`
}

ResourcesContainerModel defines the model of a container for all resource types we can collect

func CollectResources

func CollectResources(server ServerData) (*ResourcesContainerModel, error)

func FromJSONString

func FromJSONString(b []byte) (*ResourcesContainerModel, error)

func NewResourcesContainerModel

func NewResourcesContainerModel() *ResourcesContainerModel

NewResourcesContainerModel creates an empty resources container

func (*ResourcesContainerModel) CreateTopologyGraph

func (resources *ResourcesContainerModel) CreateTopologyGraph(g common.Graph)

func (*ResourcesContainerModel) GetRule

func (resources *ResourcesContainerModel) GetRule(id string) *FirewallRule

func (*ResourcesContainerModel) GetSegment

func (resources *ResourcesContainerModel) GetSegment(query string) *Segment

func (*ResourcesContainerModel) GetSegmentPort

func (resources *ResourcesContainerModel) GetSegmentPort(id string) *SegmentPort

func (*ResourcesContainerModel) GetService

func (resources *ResourcesContainerModel) GetService(query string) *Service

func (*ResourcesContainerModel) GetTier0

func (resources *ResourcesContainerModel) GetTier0(query string) *Tier0

func (*ResourcesContainerModel) GetTier1

func (resources *ResourcesContainerModel) GetTier1(query string) *Tier1

func (*ResourcesContainerModel) GetVirtualMachine

func (resources *ResourcesContainerModel) GetVirtualMachine(id string) *VirtualMachine

func (*ResourcesContainerModel) GetVirtualMachineAddresses

func (resources *ResourcesContainerModel) GetVirtualMachineAddresses(vmID string) []string

func (*ResourcesContainerModel) GetVirtualNetworkInterfaceByAddress

func (resources *ResourcesContainerModel) GetVirtualNetworkInterfaceByAddress(address string) *VirtualNetworkInterface

func (*ResourcesContainerModel) GetVirtualNetworkInterfaceByPort

func (resources *ResourcesContainerModel) GetVirtualNetworkInterfaceByPort(portID string) *VirtualNetworkInterface

func (*ResourcesContainerModel) OutputTopologyGraph

func (resources *ResourcesContainerModel) OutputTopologyGraph(fileName, format string) (res string, err error)

func (*ResourcesContainerModel) ToJSONString

func (resources *ResourcesContainerModel) ToJSONString() (string, error)

ToJSONString converts a ResourcesContainerModel into a json-formatted-string

type Rule

type Rule struct {
	nsx.Rule
	FirewallRule   *FirewallRule  `json:"firewall_rule,omitempty"`
	ServiceEntries ServiceEntries `json:"service_entries,omitempty"`
}

func (*Rule) UnmarshalJSON

func (rule *Rule) UnmarshalJSON(b []byte) error

type SecurityPolicy

type SecurityPolicy struct {
	nsx.SecurityPolicy
	Rules       []Rule        `json:"rules,omitempty"`
	DefaultRule *FirewallRule `json:"default_rule,omitempty"`
}

func (*SecurityPolicy) UnmarshalJSON

func (securityPolicy *SecurityPolicy) UnmarshalJSON(b []byte) error

type Segment

type Segment struct {
	nsx.Segment
	SegmentPorts []SegmentPort `json:"segment_ports,omitempty"`
}

func (*Segment) Kind

func (segment *Segment) Kind() string

func (*Segment) Name

func (segment *Segment) Name() string

func (*Segment) UnmarshalJSON

func (segment *Segment) UnmarshalJSON(b []byte) error

type SegmentPort

type SegmentPort struct {
	nsx.SegmentPort
}

type ServerData

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

func GetNSXServerDate

func GetNSXServerDate(host, user, password string) (ServerData, error)

func NewServerData

func NewServerData(host, user, password string) ServerData

type Service

type Service struct {
	nsx.Service
	ServiceEntries ServiceEntries `json:"service_entries,omitempty"`
}

func (*Service) UnmarshalJSON

func (service *Service) UnmarshalJSON(b []byte) error

type ServiceEntries

type ServiceEntries []ServiceEntry

func (*ServiceEntries) MarshalJSON

func (s *ServiceEntries) MarshalJSON() ([]byte, error)

func (*ServiceEntries) UnmarshalJSON

func (s *ServiceEntries) UnmarshalJSON(b []byte) error

type ServiceEntry

type ServiceEntry interface {
	ToConnection() (*netset.TransportSet, error)
	String() string
}

type Tag

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

Tag a tag used by VMs for labeling in NSX

func (*Tag) Name

func (tag *Tag) Name() string

type Tier0

type Tier0 struct {
	nsx.Tier0
	PolicyNats []PolicyNat `json:"policy_nats,omitempty"`
}

func (*Tier0) Kind

func (t0 *Tier0) Kind() string

func (*Tier0) Name

func (t0 *Tier0) Name() string

func (*Tier0) UnmarshalJSON

func (t0 *Tier0) UnmarshalJSON(b []byte) error

type Tier1

type Tier1 struct {
	nsx.Tier1
	PolicyNats []PolicyNat `json:"policy_nats,omitempty"`
}

func (*Tier1) Kind

func (t1 *Tier1) Kind() string

func (*Tier1) Name

func (t1 *Tier1) Name() string

func (*Tier1) UnmarshalJSON

func (t1 *Tier1) UnmarshalJSON(b []byte) error

type TraceFlowObservationElement

type TraceFlowObservationElement interface{}

type TraceFlowObservations

type TraceFlowObservations []TraceFlowObservationElement

func (*TraceFlowObservations) UnmarshalJSON

func (tfs *TraceFlowObservations) UnmarshalJSON(b []byte) error

type TraceFlowProtocol

type TraceFlowProtocol struct {
	SrcPort  int    `json:"src_port,omitempty"`
	DstPort  int    `json:"dst_port,omitempty"`
	Protocol string `json:"protocol,omitempty"`
}

type TraceFlows

type TraceFlows struct {
	Tfs []*traceFlow
	// contains filtered or unexported fields
}

//////////////////////////////////////////////////////////////////////////////////////////////

func NewTraceflows

func NewTraceflows(resources *ResourcesContainerModel, server ServerData) *TraceFlows

func (*TraceFlows) AddTraceFlow

func (traceFlows *TraceFlows) AddTraceFlow(src, dst string, protocol TraceFlowProtocol,
	analyzeAllowed bool, srcRuleID, dstRuleID []int, connection string)

func (*TraceFlows) Execute

func (traceFlows *TraceFlows) Execute()

func (*TraceFlows) Summary

func (traceFlows *TraceFlows) Summary()

func (*TraceFlows) ToJSONString

func (traceFlows *TraceFlows) ToJSONString() (string, error)

ToJSONString converts a traceFlows into a json-formatted-string, it converts only the Tfs

type TraceflowConfig

type TraceflowConfig struct {
	// Configuration of packet data
	Packet *nsx.FieldsPacketData `json:"packet,omitempty" yaml:"packet,omitempty" mapstructure:"packet,omitempty"`
	// Policy path or UUID (validated for syntax only) of segment port to start
	// traceflow from. Auto-plumbed ports don't have corresponding policy path. Both
	// overlay backed port and VLAN backed port are supported.
	SourceID *string `json:"source_id,omitempty"`
}

///////////////////////////////////////////////////////////////////////////////////////

func (*TraceflowConfig) UnmarshalJSON

func (config *TraceflowConfig) UnmarshalJSON(b []byte) error

type TraceflowObservationDelivered

type TraceflowObservationDelivered struct {
	nsx.TraceflowObservationDelivered
}

type TraceflowObservationDropped

type TraceflowObservationDropped struct {
	nsx.TraceflowObservationDropped
}

type TraceflowObservationDroppedLogical

type TraceflowObservationDroppedLogical struct {
	nsx.TraceflowObservationDroppedLogical
}

type TraceflowObservationForwarded

type TraceflowObservationForwarded struct {
	nsx.TraceflowObservationForwarded
}

type TraceflowObservationForwardedLogical

type TraceflowObservationForwardedLogical struct {
	nsx.TraceflowObservationForwardedLogical
}

type TraceflowObservationProtected

type TraceflowObservationProtected struct {
	nsx.TraceflowObservationProtected
}

type TraceflowObservationReceived

type TraceflowObservationReceived struct {
	nsx.TraceflowObservationReceived
}

type TraceflowObservationReceivedLogical

type TraceflowObservationReceivedLogical struct {
	nsx.TraceflowObservationReceivedLogical
}

type TraceflowObservationRelayedLogical

type TraceflowObservationRelayedLogical struct {
	nsx.TraceflowObservationRelayedLogical
}

type TraceflowObservationReplicationLogical

type TraceflowObservationReplicationLogical struct {
	nsx.TraceflowObservationReplicationLogical
}

type VirtualMachine

type VirtualMachine struct {
	nsx.VirtualMachine
}

func (*VirtualMachine) Kind

func (vm *VirtualMachine) Kind() string

func (*VirtualMachine) Name

func (vm *VirtualMachine) Name() string

type VirtualNetworkInterface

type VirtualNetworkInterface struct {
	nsx.VirtualNetworkInterface
}

func (*VirtualNetworkInterface) Kind

func (vni *VirtualNetworkInterface) Kind() string

func (*VirtualNetworkInterface) Name

func (vni *VirtualNetworkInterface) Name() string

func (*VirtualNetworkInterface) UnmarshalJSON

func (vni *VirtualNetworkInterface) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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