utils

package
v0.0.0-...-4aa9b4e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoRequestWithRetry

func DoRequestWithRetry(req *http.Request, client *http.Client, logger zerolog.Logger) (*http.Response, error)

Types

type Block

type Block struct {
	Type string `json:"type,omitempty"`
	Text *Text  `json:"text,omitempty"`
}

type CSVUtils

type CSVUtils struct {
	FilePath   string
	FileSystem afero.Fs
}

func NewCSVUtils

func NewCSVUtils(filePath string) CSVUtils

func (CSVUtils) GetDependenciesList

func (csvU CSVUtils) GetDependenciesList() ([]DepList, error)

type CSVUtilsInterface

type CSVUtilsInterface interface {
	GetDependenciesList() ([]DepList, error)
}

type CVE

type CVE struct {
	ID          primitive.ObjectID `bson:"_id"`
	CreatedAt   time.Time          `bson:"created_at"`
	UpdatedAt   time.Time          `bson:"updated_at"`
	Vendor      string             `bson:"vendor"`
	Product     string             `bson:"product"`
	Severity    string             `bson:"severity"`
	CVEId       string             `bson:"cve_id"`
	Description string             `bson:"description"`
	Score       float64
}

type DepList

type DepList struct {
	Vendor  string
	Product string
}

type FakeCVEParam

type FakeCVEParam struct {
	Id          string
	Description string
	Severity    string
	Score       float64
}

type MongoUtils

type MongoUtils struct {
	DbUri       string
	CtxDuration time.Duration
	Logger      zerolog.Logger
}

func NewMongoUtils

func NewMongoUtils(dbUri string, logger zerolog.Logger) MongoUtils

func (MongoUtils) CVEExists

func (mu MongoUtils) CVEExists(cveId string, ctx context.Context, collection *mongo.Collection) (bool, error)

func (MongoUtils) CreateCVE

func (mu MongoUtils) CreateCVE(cve *CVE, ctx context.Context, collection *mongo.Collection) error

func (MongoUtils) DisconnectMongoClient

func (mu MongoUtils) DisconnectMongoClient(client *mongo.Client, ctx context.Context) error

func (MongoUtils) FindCVE

func (mu MongoUtils) FindCVE(product string, ctx context.Context, collection *mongo.Collection) (CVE, error)

func (MongoUtils) GetAllCVEs

func (mu MongoUtils) GetAllCVEs(ctx context.Context, collection *mongo.Collection) ([]CVE, error)

func (MongoUtils) GetMongoClient

func (mu MongoUtils) GetMongoClient() (*mongo.Client, context.Context, error)

func (MongoUtils) GetMongoCollection

func (mu MongoUtils) GetMongoCollection(client mongo.Client, database, collection string) *mongo.Collection

func (MongoUtils) GetUniqueDependencies

func (mu MongoUtils) GetUniqueDependencies(ctx context.Context, collection *mongo.Collection) ([]CVE, error)

func (MongoUtils) RemoveAllCVEs

func (mu MongoUtils) RemoveAllCVEs(product string, ctx context.Context, collection *mongo.Collection) error

type MongoUtilsInterface

type MongoUtilsInterface interface {
	GetMongoClient() (*mongo.Client, context.Context, error)
	DisconnectMongoClient(client *mongo.Client, ctx context.Context) error
	GetMongoCollection(client mongo.Client, database, collection string) *mongo.Collection
	CreateCVE(cve *CVE, ctx context.Context, collection *mongo.Collection) error
	GetUniqueDependencies(ctx context.Context, collection *mongo.Collection) ([]CVE, error)
	FindCVE(product string, ctx context.Context, collection *mongo.Collection) (CVE, error)
	RemoveAllCVEs(product string, ctx context.Context, collection *mongo.Collection) error
	CVEExists(cveId string, ctx context.Context, collection *mongo.Collection) (bool, error)
	GetAllCVEs(ctx context.Context, collection *mongo.Collection) ([]CVE, error)
}

type NVDNistResponse

type NVDNistResponse struct {
	ResultsPerPage  int                      `json:"resultsPerPage"`
	StartIndex      int                      `json:"startIndex"`
	TotalResults    int                      `json:"totalResults"`
	Format          string                   `json:"format"`
	Version         string                   `json:"version"`
	Timestamp       string                   `json:"timestamp"`
	Vulnerabilities []NVDNistResponseCVEItem `json:"vulnerabilities"`
}

type NVDNistResponseCVE

type NVDNistResponseCVE struct {
	Id               string `json:"id"`
	SourceIdentifier string `json:"sourceIdentifier"`
	Published        string `json:"published"`
	LastModified     string `json:"lastModified"`
	VulnStatus       string `json:"vulnStatus"`
	Descriptions     []struct {
		Lang  string `json:"lang"`
		Value string `json:"value"`
	} `json:"descriptions"`

	Metrics struct {
		CvssMetricV2 []NVDNistResponseCVEMetrics `json:"cvssMetricV2,omitempty"`
		CvssMetricV3 []NVDNistResponseCVEMetrics `json:"cvssMetricV31,omitempty"`
	} `json:"metrics"`
}

type NVDNistResponseCVEItem

type NVDNistResponseCVEItem struct {
	CVE NVDNistResponseCVE `json:"cve"`
}

func GenerateFakeCVE

func GenerateFakeCVE(params []FakeCVEParam) []NVDNistResponseCVEItem

type NVDNistResponseCVEMetrics

type NVDNistResponseCVEMetrics struct {
	CvssData struct {
		BaseScore    float64 `json:"baseScore"`
		BaseSeverity string  `json:"baseSeverity"`
	} `json:"cvssData"`
}

type NVDNistUtils

type NVDNistUtils struct {
	ResultsPerPage int
	BaseUrl        string
	Client         http.Client
	ApiKey         string
}

func NewNVDNistUtils

func NewNVDNistUtils(nvdNistApiKey string) NVDNistUtils

func (NVDNistUtils) GetCVEs

func (nvd NVDNistUtils) GetCVEs(vendor, product string, logger zerolog.Logger) ([]NVDNistResponseCVEItem, error)

type NVDNistUtilsInterface

type NVDNistUtilsInterface interface {
	GetCVEs(vendor, product string, logger zerolog.Logger) ([]NVDNistResponseCVEItem, error)
}

type Payload

type Payload struct {
	Blocks []Block `json:"blocks,omitempty"`
	Text   string  `json:"text,omitempty"`
}

type SlackUtils

type SlackUtils struct {
	WebhookUrl string
	Client     http.Client
}

func NewSlackUtils

func NewSlackUtils(webhookUrl string) SlackUtils

func (SlackUtils) SendNewCVENotification

func (s SlackUtils) SendNewCVENotification(product, cveId, description, severity string, score float64) error

type SlackUtilsInterface

type SlackUtilsInterface interface {
	SendNewCVENotification(product, cveId, description, severity string, score float64) error
}

type Text

type Text struct {
	Type  string `json:"type,omitempty"`
	Text  string `json:"text,omitempty"`
	Emoji bool   `json:"emoji,omitempty"`
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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