inventory

package
v0.0.0-...-27baac2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategoryInfrastructure assetCategory = "infrastructure"
	CategoryIdentity       assetCategory = "identity"
)
View Source
const (
	SubCategoryCompute assetSubCategory = "compute"
	SubCategoryStorage assetSubCategory = "storage"

	SubCategoryCloudProviderAccount assetSubCategory = "cloud-provider-account"
)
View Source
const (
	TypeVirtualMachine assetType = "virtual-machine"
	TypeObjectStorage  assetType = "object-storage"

	TypeUser           assetType = "user"
	TypeServiceAccount assetType = "service-account"
	TypePermissions    assetType = "permissions"
)
View Source
const (
	SubTypeEC2 assetSubType = "ec2"
	SubTypeS3  assetSubType = "s3"
	SubTypeIAM assetSubType = "iam"
)
View Source
const (
	AwsCloudProvider = "aws"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	UUID string `json:"uuid"`
	Id   string `json:"id"`
	Name string `json:"name"`
	AssetClassification
	Tags map[string]string `json:"tags"`
	Raw  any               `json:"raw"`
}

Asset contains the identifiers of the asset

type AssetClassification

type AssetClassification struct {
	Category    assetCategory    `json:"category"`
	SubCategory assetSubCategory `json:"sub_category"`
	Type        assetType        `json:"type"`
	SubType     assetSubType     `json:"sub_type"`
}

AssetClassification holds the taxonomy of an asset

type AssetCloud

type AssetCloud struct {
	AvailabilityZone *string             `json:"availability_zone,omitempty"`
	Provider         string              `json:"provider,omitempty"`
	Region           string              `json:"region,omitempty"`
	Account          AssetCloudAccount   `json:"account"`
	Instance         *AssetCloudInstance `json:"instance,omitempty"`
	Machine          *AssetCloudMachine  `json:"machine,omitempty"`
	Project          *AssetCloudProject  `json:"project,omitempty"`
	Service          *AssetCloudService  `json:"service,omitempty"`
}

AssetCloud contains information about the cloud provider

type AssetCloudAccount

type AssetCloudAccount struct {
	Id   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type AssetCloudInstance

type AssetCloudInstance struct {
	Id   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type AssetCloudMachine

type AssetCloudMachine struct {
	MachineType string `json:"machine_type,omitempty"`
}

type AssetCloudProject

type AssetCloudProject struct {
	Id   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type AssetCloudService

type AssetCloudService struct {
	Name string `json:"name,omitempty"`
}

type AssetEnricher

type AssetEnricher func(asset *AssetEvent)

AssetEnricher functional builder function

func EmptyEnricher

func EmptyEnricher() AssetEnricher

func WithCloud

func WithCloud(cloud AssetCloud) AssetEnricher

func WithHost

func WithHost(host AssetHost) AssetEnricher

func WithIAM

func WithIAM(iam AssetIAM) AssetEnricher

func WithNetwork

func WithNetwork(network AssetNetwork) AssetEnricher

func WithRawAsset

func WithRawAsset(raw any) AssetEnricher

func WithResourcePolicies

func WithResourcePolicies(policies ...AssetResourcePolicy) AssetEnricher

func WithTags

func WithTags(tags map[string]string) AssetEnricher

type AssetEvent

type AssetEvent struct {
	Asset            Asset
	Network          *AssetNetwork
	Cloud            *AssetCloud
	Host             *AssetHost
	IAM              *AssetIAM
	ResourcePolicies []AssetResourcePolicy
}

AssetEvent holds the whole asset

func NewAssetEvent

func NewAssetEvent(c AssetClassification, id string, name string, enrichers ...AssetEnricher) AssetEvent

type AssetFetcher

type AssetFetcher interface {
	Fetch(ctx context.Context, assetChannel chan<- AssetEvent)
}

type AssetHost

type AssetHost struct {
	Architecture    string  `json:"architecture"`
	ImageId         *string `json:"imageId"`
	InstanceType    string  `json:"instance_type"`
	Platform        string  `json:"platform"`
	PlatformDetails *string `json:"platform_details"`
}

AssetHost contains information of the asset in case it is a host

type AssetIAM

type AssetIAM struct {
	Id  *string `json:"id"`
	Arn *string `json:"arn"`
}

type AssetInventory

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

func NewAssetInventory

func NewAssetInventory(logger *logp.Logger, fetchers []AssetFetcher, publisher AssetPublisher, now func() time.Time) AssetInventory

func (*AssetInventory) Run

func (a *AssetInventory) Run(ctx context.Context)

func (*AssetInventory) Stop

func (a *AssetInventory) Stop()

type AssetNetwork

type AssetNetwork struct {
	NetworkId        *string `json:"network_id"`
	SubnetId         *string `json:"subnet_id"`
	Ipv6Address      *string `json:"ipv6_address"`
	PublicIpAddress  *string `json:"public_ip_address"`
	PrivateIpAddress *string `json:"private_ip_address"`
	PublicDnsName    *string `json:"public_dns_name"`
	PrivateDnsName   *string `json:"private_dns_name"`
}

AssetNetwork contains network information

type AssetPublisher

type AssetPublisher interface {
	PublishAll([]beat.Event)
}

type AssetResourcePolicy

type AssetResourcePolicy struct {
	Version    *string        `json:"version,omitempty"`
	Id         *string        `json:"id,omitempty"`
	Effect     string         `json:"effect,omitempty"`
	Principal  map[string]any `json:"principal,omitempty"`
	Action     []string       `json:"action,omitempty"`
	NotAction  []string       `json:"notAction,omitempty"`
	Resource   []string       `json:"resource,omitempty"`
	NoResource []string       `json:"noResource,omitempty"`
	Condition  map[string]any `json:"condition,omitempty"`
}

AssetResourcePolicy maps security policies applied directly on resources

type MockAssetEnricher

type MockAssetEnricher struct {
	mock.Mock
}

MockAssetEnricher is an autogenerated mock type for the AssetEnricher type

func NewMockAssetEnricher

func NewMockAssetEnricher(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockAssetEnricher

NewMockAssetEnricher creates a new instance of MockAssetEnricher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockAssetEnricher) EXPECT

func (*MockAssetEnricher) Execute

func (_m *MockAssetEnricher) Execute(asset *AssetEvent)

Execute provides a mock function with given fields: asset

type MockAssetEnricher_Execute_Call

type MockAssetEnricher_Execute_Call struct {
	*mock.Call
}

MockAssetEnricher_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute'

func (*MockAssetEnricher_Execute_Call) Return

func (*MockAssetEnricher_Execute_Call) Run

func (*MockAssetEnricher_Execute_Call) RunAndReturn

type MockAssetEnricher_Expecter

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

func (*MockAssetEnricher_Expecter) Execute

func (_e *MockAssetEnricher_Expecter) Execute(asset interface{}) *MockAssetEnricher_Execute_Call

Execute is a helper method to define mock.On call

  • asset *AssetEvent

type MockAssetFetcher

type MockAssetFetcher struct {
	mock.Mock
}

MockAssetFetcher is an autogenerated mock type for the AssetFetcher type

func NewMockAssetFetcher

func NewMockAssetFetcher(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockAssetFetcher

NewMockAssetFetcher creates a new instance of MockAssetFetcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockAssetFetcher) EXPECT

func (*MockAssetFetcher) Fetch

func (_m *MockAssetFetcher) Fetch(ctx context.Context, assetChannel chan<- AssetEvent)

Fetch provides a mock function with given fields: ctx, assetChannel

type MockAssetFetcher_Expecter

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

func (*MockAssetFetcher_Expecter) Fetch

func (_e *MockAssetFetcher_Expecter) Fetch(ctx interface{}, assetChannel interface{}) *MockAssetFetcher_Fetch_Call

Fetch is a helper method to define mock.On call

  • ctx context.Context
  • assetChannel chan<- AssetEvent

type MockAssetFetcher_Fetch_Call

type MockAssetFetcher_Fetch_Call struct {
	*mock.Call
}

MockAssetFetcher_Fetch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Fetch'

func (*MockAssetFetcher_Fetch_Call) Return

func (*MockAssetFetcher_Fetch_Call) Run

func (_c *MockAssetFetcher_Fetch_Call) Run(run func(ctx context.Context, assetChannel chan<- AssetEvent)) *MockAssetFetcher_Fetch_Call

func (*MockAssetFetcher_Fetch_Call) RunAndReturn

type MockAssetPublisher

type MockAssetPublisher struct {
	mock.Mock
}

MockAssetPublisher is an autogenerated mock type for the AssetPublisher type

func NewMockAssetPublisher

func NewMockAssetPublisher(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockAssetPublisher

NewMockAssetPublisher creates a new instance of MockAssetPublisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockAssetPublisher) EXPECT

func (*MockAssetPublisher) PublishAll

func (_m *MockAssetPublisher) PublishAll(_a0 []beat.Event)

PublishAll provides a mock function with given fields: _a0

type MockAssetPublisher_Expecter

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

func (*MockAssetPublisher_Expecter) PublishAll

func (_e *MockAssetPublisher_Expecter) PublishAll(_a0 interface{}) *MockAssetPublisher_PublishAll_Call

PublishAll is a helper method to define mock.On call

  • _a0 []beat.Event

type MockAssetPublisher_PublishAll_Call

type MockAssetPublisher_PublishAll_Call struct {
	*mock.Call
}

MockAssetPublisher_PublishAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishAll'

func (*MockAssetPublisher_PublishAll_Call) Return

func (*MockAssetPublisher_PublishAll_Call) Run

func (*MockAssetPublisher_PublishAll_Call) RunAndReturn

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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