scanner

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package scanner scans targets

Package scanner scans targets

Package scanner scans targets

Package scanner scans targets

Package scanner scans targets

Package scanner scans targets

Package scanner scans targets

Package scanner scans targets

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSEC2

type AWSEC2 struct {
	SourceName string
	Ec2Client  Ec2Client
	Region     string
	AccountID  string
	Fields     []string
	// contains filtered or unexported fields
}

AWSEC2 AWS Ec2 source

func (*AWSEC2) GetKind

func (a *AWSEC2) GetKind() string

GetKind return resource kind

func (*AWSEC2) GetName

func (a *AWSEC2) GetName() string

GetName return source name

func (*AWSEC2) GetSchedule

func (a *AWSEC2) GetSchedule() string

GetSchedule return schedule

func (*AWSEC2) Scan

func (a *AWSEC2) Scan(resourceChannel chan resource.Resource) error

Scan discover resource and send to resource channel

func (*AWSEC2) Setup

func (a *AWSEC2) Setup(name string, cfg config.Source, dependencies *Dependencies) error

Setup AWS EC2 source

type AWSECR

type AWSECR struct {
	SourceName             string
	ECRClient              EcrClient
	Region                 string
	AccountID              string
	ResourceTaggingService util.ResourceTaggingServiceClient
	Fields                 []string
	// contains filtered or unexported fields
}

AWSECR AWS ECR source

func (*AWSECR) GetKind

func (a *AWSECR) GetKind() string

GetKind return resource kind

func (*AWSECR) GetName

func (a *AWSECR) GetName() string

GetName return source name

func (*AWSECR) GetSchedule

func (a *AWSECR) GetSchedule() string

GetSchedule return schedule

func (*AWSECR) Scan

func (a *AWSECR) Scan(resourceChannel chan resource.Resource) error

Scan discover resource and send to resource channel

func (*AWSECR) Setup

func (a *AWSECR) Setup(name string, cfg config.Source, dependencies *Dependencies) error

Setup AWS ECR source

type AWSRDS

type AWSRDS struct {
	SourceName string
	RdsClient  RdsClient
	Region     string
	AccountID  string
	Fields     []string
	// contains filtered or unexported fields
}

AWSRDS AWS S3 source

func (*AWSRDS) GetKind

func (a *AWSRDS) GetKind() string

GetKind return resource kind

func (*AWSRDS) GetName

func (a *AWSRDS) GetName() string

GetName return source name

func (*AWSRDS) GetSchedule

func (a *AWSRDS) GetSchedule() string

GetSchedule return schedule

func (*AWSRDS) Scan

func (a *AWSRDS) Scan(resourceChannel chan resource.Resource) error

Scan discover resource and send to resource channel

func (*AWSRDS) Setup

func (a *AWSRDS) Setup(name string, cfg config.Source, dependencies *Dependencies) error

Setup AWS S3 source

type AWSS3

type AWSS3 struct {
	SourceName string
	S3Client   AWSS3Client
	Region     string
	Fields     []string
	// contains filtered or unexported fields
}

AWSS3 AWS S3 source

func (*AWSS3) GetKind

func (a *AWSS3) GetKind() string

GetKind return resource kind

func (*AWSS3) GetName

func (a *AWSS3) GetName() string

GetName return source name

func (*AWSS3) GetSchedule

func (a *AWSS3) GetSchedule() string

GetSchedule return schedule

func (*AWSS3) Scan

func (a *AWSS3) Scan(resourceChannel chan resource.Resource) error

Scan discover resource and send to resource channel

func (*AWSS3) Setup

func (a *AWSS3) Setup(name string, cfg config.Source, dependencies *Dependencies) error

Setup AWS S3 source

type AWSS3Client

type AWSS3Client interface {
	ListBuckets(ctx context.Context, params *s3.ListBucketsInput, optFns ...func(*s3.Options)) (*s3.ListBucketsOutput, error)
	GetBucketTagging(ctx context.Context, params *s3.GetBucketTaggingInput, optFns ...func(*s3.Options)) (*s3.GetBucketTaggingOutput, error)
}

AWSS3Client build aws client

type Dependencies

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

Dependencies scanner dependencies

func NewScannerDependencies

func NewScannerDependencies(scheduler scheduler.Scheduler, storage storage.Storage, logger *logrus.Logger, metricsCollector *metrics.Collector) *Dependencies

NewScannerDependencies construct new scanner dependencies

func (*Dependencies) GetLogger

func (d *Dependencies) GetLogger() *logrus.Logger

GetLogger return logger

func (*Dependencies) GetMetrics

func (d *Dependencies) GetMetrics() *metrics.Collector

GetMetrics return metrics

func (*Dependencies) GetScheduler

func (d *Dependencies) GetScheduler() scheduler.Scheduler

GetScheduler return scheduler

func (*Dependencies) GetStorage

func (d *Dependencies) GetStorage() storage.Storage

GetStorage return storage

type Ec2Client

type Ec2Client interface {
	DescribeInstances(ctx context.Context, params *ec2.DescribeInstancesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)
}

Ec2Client build aws client

type EcrClient

type EcrClient interface {
	DescribeRepositories(context.Context, *ecr.DescribeRepositoriesInput, ...func(options *ecr.Options)) (*ecr.DescribeRepositoriesOutput, error)
	GetRepositoryPolicy(ctx context.Context, params *ecr.GetRepositoryPolicyInput, optFns ...func(*ecr.Options)) (*ecr.GetRepositoryPolicyOutput, error)
	DescribeImages(context.Context, *ecr.DescribeImagesInput, ...func(*ecr.Options)) (*ecr.DescribeImagesOutput, error)
}

EcrClient build aws client

type Factory

type Factory func() Scanner

Factory is a function that returns a new instance of a Scanner.

type FieldMapper

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

FieldMapper is a structure that helps in mapping various fields and tags to resource.MetaData structures.

func NewFieldMapper

func NewFieldMapper(mappings map[string]func() string, tags func() []ResourceTag, fields []string) *FieldMapper

NewFieldMapper initializes and returns a new instance of FieldMapper.

type File

type File struct {
	Path string
}

File represent file information

type FsScanner

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

FsScanner store configuration for file system scanner

func (*FsScanner) GetKind

func (s *FsScanner) GetKind() string

GetKind return resource kind

func (*FsScanner) GetName

func (s *FsScanner) GetName() string

GetName return name

func (*FsScanner) GetSchedule

func (s *FsScanner) GetSchedule() string

GetSchedule return schedule

func (*FsScanner) Scan

func (s *FsScanner) Scan(resourceChannel chan resource.Resource) error

Scan scans the file system

func (*FsScanner) Setup

func (s *FsScanner) Setup(name string, cfg config.Source, dependencies *Dependencies) error

Setup setup file system scanner

type GitHubClient

type GitHubClient interface {
	ListRepositories(ctx context.Context, user string, opts *github.RepositoryListOptions) ([]*github.Repository, error)
}

GitHubClient present interface to build GitHub client

type GitHubRepositoryClient

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

GitHubRepositoryClient GitHub repository client

func NewGitHubRepositoryClient

func NewGitHubRepositoryClient(client *github.Client, logger *logrus.Logger) *GitHubRepositoryClient

NewGitHubRepositoryClient construct new GitHub repository client

func (*GitHubRepositoryClient) ListRepositories

func (c *GitHubRepositoryClient) ListRepositories(ctx context.Context, user string, opts *github.RepositoryListOptions) ([]*github.Repository, error)

ListRepositories provide list of repositories from GitHub

type GitHubRepositoryScanner

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

GitHubRepositoryScanner GitHub repository scanner

func (*GitHubRepositoryScanner) GetKind

func (r *GitHubRepositoryScanner) GetKind() string

GetKind return resource kind

func (*GitHubRepositoryScanner) GetName

func (r *GitHubRepositoryScanner) GetName() string

GetName return name

func (*GitHubRepositoryScanner) GetSchedule

func (r *GitHubRepositoryScanner) GetSchedule() string

GetSchedule return schedule

func (*GitHubRepositoryScanner) Scan

func (r *GitHubRepositoryScanner) Scan(resourceChannel chan resource.Resource) error

Scan scans GitHub to get the list of repositories as resources

func (*GitHubRepositoryScanner) Setup

func (r *GitHubRepositoryScanner) Setup(name string, cfg config.Source, dependencies *Dependencies) error

Setup GitHub repository scanner

type MetaDataMapper

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

MetaDataMapper map the fields

type Mock

type Mock struct {
	mock.Mock
}

Mock is an autogenerated mock type for the ScannerMock type

func (*Mock) GetKind

func (_m *Mock) GetKind() string

GetKind provides a mock function with given fields:

func (*Mock) GetName

func (_m *Mock) GetName() string

GetName provides a mock function with given fields:

func (*Mock) GetSchedule

func (_m *Mock) GetSchedule() string

GetSchedule provides a mock function with given fields:

func (*Mock) Scan

func (_m *Mock) Scan(resourceChannel chan resource.Resource) error

Scan provides a mock function with given fields: resourceChannel

func (*Mock) Setup

func (_m *Mock) Setup(name string, cfg config.Source, dependencies *Dependencies) error

Setup provides a mock function with given fields: name, cfg, dependencies

type RdsClient

type RdsClient interface {
	DescribeDBInstances(context.Context, *rds.DescribeDBInstancesInput, ...func(*rds.Options)) (*rds.DescribeDBInstancesOutput, error)
}

RdsClient build aws client

type ResourceTag

type ResourceTag struct {
	Key   string
	Value string
}

ResourceTag represents a tag on any resource.

type Scanner

type Scanner interface {
	Setup(name string, cfg config.Source, dependencies *Dependencies) error
	Scan(resourceChannel chan resource.Resource) error
	GetName() string
	GetKind() string
	GetSchedule() string
}

Scanner interface to build different scanner

func BuildScanners

func BuildScanners(sources map[string]config.Source, dependencies *Dependencies) []Scanner

BuildScanners build source based on configuration

type Scanners

type Scanners struct {
	Scanners []Scanner
}

Scanners list of scanners

Jump to

Keyboard shortcuts

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