services

package
v0.0.0-...-a838a9a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DATABASE = "buildpacks"

Functions

func DoRequestWithRetry

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

Types

type Block

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

type CSVReaderLibrary

type CSVReaderLibrary struct {
	FilePath   string
	FileSystem afero.Fs
}

func NewCSVReaderLibrary

func NewCSVReaderLibrary(filePath string) CSVReaderLibrary

func (CSVReaderLibrary) GetDependenciesList

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

type CSVReaderLibraryInterface

type CSVReaderLibraryInterface 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            `bson:"score"`
}

type DepList

type DepList struct {
	Vendor  string
	Product string
}

type Dependency

type Dependency struct {
	Id         string `json:"id,omitempty" bson:"_id,omitempty"`
	Dependency string `json:"dependency"`
	Product    string `json:"product"`
	Vendor     string `json:"vendor"`
}

type DependencyWithIntegration

type DependencyWithIntegration struct {
	DependencyId string      `json:"dependency_id"`
	Integration  Integration `json:"integration"`
}

type FakeCVEParam

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

type Integration

type Integration struct {
	Type     string `json:"type"`
	Active   bool   `json:"active"`
	Settings string `json:"settings"`
}

type MongoLibrary

type MongoLibrary struct {
	DbUri       string
	CtxDuration time.Duration
}

func NewMongoLibrary

func NewMongoLibrary(dbUri string) MongoLibrary

func (MongoLibrary) AddTrackedDependencies

func (mu MongoLibrary) AddTrackedDependencies(ctx context.Context, client *mongo.Client, dependencies []Dependency) error

func (MongoLibrary) CVEExists

func (mu MongoLibrary) CVEExists(ctx context.Context, client *mongo.Client, cveId string) (bool, error)

func (MongoLibrary) CreateCVE

func (mu MongoLibrary) CreateCVE(ctx context.Context, client *mongo.Client, cve *CVE) error

func (MongoLibrary) DisconnectMongoClient

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

func (MongoLibrary) FindCVE

func (mu MongoLibrary) FindCVE(ctx context.Context, client *mongo.Client, product string) (CVE, error)

func (MongoLibrary) FindUserByUsername

func (mu MongoLibrary) FindUserByUsername(ctx context.Context, client *mongo.Client, username string) (bool, User, error)

func (MongoLibrary) GetAllCVEs

func (mu MongoLibrary) GetAllCVEs(ctx context.Context, client *mongo.Client) ([]CVE, error)

func (MongoLibrary) GetMongoClient

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

func (MongoLibrary) GetMongoCollection

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

func (MongoLibrary) GetTrackedDependencies

func (mu MongoLibrary) GetTrackedDependencies(ctx context.Context, client *mongo.Client) ([]Dependency, error)

func (MongoLibrary) GetUniqueDependencies

func (mu MongoLibrary) GetUniqueDependencies(ctx context.Context, client *mongo.Client) ([]CVE, error)

func (MongoLibrary) GetUserDependencies

func (mu MongoLibrary) GetUserDependencies(ctx context.Context, client *mongo.Client, userId string) (UserDependencies, error)

func (MongoLibrary) RegisterUser

func (mu MongoLibrary) RegisterUser(ctx context.Context, client *mongo.Client, user User) error

func (MongoLibrary) RemoveAllCVEs

func (mu MongoLibrary) RemoveAllCVEs(ctx context.Context, client *mongo.Client, product string) error

func (MongoLibrary) RemoveTrackedDependencies

func (mu MongoLibrary) RemoveTrackedDependencies(ctx context.Context, client *mongo.Client, dependencies []Dependency) error

func (MongoLibrary) UpdateUserDependencies

func (mu MongoLibrary) UpdateUserDependencies(ctx context.Context, client *mongo.Client, userId string, userDeps []DependencyWithIntegration) error

type MongoLibraryInterface

type MongoLibraryInterface 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(ctx context.Context, client *mongo.Client, cve *CVE) error
	GetUniqueDependencies(ctx context.Context, client *mongo.Client) ([]CVE, error)
	FindCVE(ctx context.Context, client *mongo.Client, product string) (CVE, error)
	RemoveAllCVEs(ctx context.Context, client *mongo.Client, product string) error
	CVEExists(ctx context.Context, client *mongo.Client, cveId string) (bool, error)
	GetAllCVEs(ctx context.Context, client *mongo.Client) ([]CVE, error)
	GetTrackedDependencies(ctx context.Context, client *mongo.Client) ([]Dependency, error)
	AddTrackedDependencies(ctx context.Context, client *mongo.Client, dependencies []Dependency) error
	RemoveTrackedDependencies(ctx context.Context, client *mongo.Client, dependencies []Dependency) error
	RegisterUser(ctx context.Context, client *mongo.Client, user User) error
	FindUserByUsername(ctx context.Context, client *mongo.Client, username string) (bool, User, error)
	GetUserDependencies(ctx context.Context, client *mongo.Client, userId string) (UserDependencies, error)
	UpdateUserDependencies(ctx context.Context, client *mongo.Client, userId string, userDeps []DependencyWithIntegration) error
}

type NVDNistLibrary

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

func NewNVDNistLibrary

func NewNVDNistLibrary(nvdNistApiKey string) NVDNistLibrary

func (NVDNistLibrary) GetCVEs

func (nvd NVDNistLibrary) GetCVEs(vendor, product string) ([]NVDNistResponseCVEItem, error)

type NVDNistLibraryInterface

type NVDNistLibraryInterface interface {
	GetCVEs(vendor, product string) ([]NVDNistResponseCVEItem, 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 Payload

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

type SlackLibrary

type SlackLibrary struct {
	WebhookUrl string
	Client     http.Client
}

func NewSlackLibrary

func NewSlackLibrary(webhookUrl string) SlackLibrary

func (SlackLibrary) SendNewCVENotification

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

type SlackLibraryInterface

type SlackLibraryInterface 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"`
}

type User

type User struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type UserDependencies

type UserDependencies struct {
	UserID              string                      `json:"user_id" bson:"user_id"`
	DependenciesWithInt []DependencyWithIntegration `json:"dependencies_with_integration" bson:"dependencies_with_integration"`
}

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