db

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New() *Client

func NewMock

func NewMock(t *testing.T) *Client

func (*Client) AssignRepoLabel added in v0.1.4

func (x *Client) AssignRepoLabel(ctx *model.Context, repoID int, labelID int) error

func (*Client) AssignSeverity added in v0.1.1

func (x *Client) AssignSeverity(ctx *model.Context, vulnID string, id int) error

func (*Client) Close

func (x *Client) Close() error

func (*Client) CreateRepo

func (x *Client) CreateRepo(ctx *model.Context, repo *ent.Repository) (*ent.Repository, error)

func (*Client) CreateRepoLabel added in v0.1.4

func (x *Client) CreateRepoLabel(ctx *model.Context, req *model.RequestRepoLabel) (*ent.RepoLabel, error)

Repository Label

func (*Client) CreateSeverity added in v0.1.1

func (x *Client) CreateSeverity(ctx *model.Context, req *model.RequestSeverity) (*ent.Severity, error)

Severity

func (*Client) DeleteRepoLabel added in v0.1.4

func (x *Client) DeleteRepoLabel(ctx *model.Context, id int) error

func (*Client) DeleteSession

func (x *Client) DeleteSession(ctx *model.Context, ssnID string) error

func (*Client) DeleteSeverity added in v0.1.1

func (x *Client) DeleteSeverity(ctx *model.Context, id int) error

func (*Client) GetLatestScan

func (x *Client) GetLatestScan(ctx *model.Context, branch model.GitHubBranch) (*ent.Scan, error)

func (*Client) GetLatestScans

func (x *Client) GetLatestScans(ctx *model.Context) ([]*ent.Scan, error)

func (*Client) GetLatestVulnerabilities

func (x *Client) GetLatestVulnerabilities(ctx *model.Context, offset int, limit int) ([]*ent.Vulnerability, error)

func (*Client) GetRepoLabels added in v0.1.4

func (x *Client) GetRepoLabels(ctx *model.Context) ([]*ent.RepoLabel, error)

func (*Client) GetRepositories

func (x *Client) GetRepositories(ctx *model.Context) ([]*ent.Repository, error)

func (*Client) GetRepositoriesWithVuln

func (x *Client) GetRepositoriesWithVuln(ctx *model.Context, vulnID string) ([]*ent.Repository, error)

func (*Client) GetRepository added in v0.1.4

func (x *Client) GetRepository(ctx *model.Context, repo *model.GitHubRepo) (*ent.Repository, error)

func (*Client) GetRepositoryScan added in v0.1.4

func (x *Client) GetRepositoryScan(ctx *model.Context, req *model.GetRepoScanRequest) ([]*ent.Scan, error)

func (*Client) GetScan

func (x *Client) GetScan(ctx *model.Context, id string) (*ent.Scan, error)

func (*Client) GetSession

func (x *Client) GetSession(ctx *model.Context, ssnID string, now int64) (*ent.Session, error)

func (*Client) GetSeverities added in v0.1.1

func (x *Client) GetSeverities(ctx *model.Context) ([]*ent.Severity, error)

func (*Client) GetUser

func (x *Client) GetUser(ctx *model.Context, userID int) (*ent.User, error)

func (*Client) GetVulnStatus

func (x *Client) GetVulnStatus(ctx *model.Context, repo *model.GitHubRepo) ([]*ent.VulnStatus, error)

func (*Client) GetVulnerability

func (x *Client) GetVulnerability(ctx *model.Context, id string) (*ent.Vulnerability, error)

func (*Client) GetVulnerabilityCount

func (x *Client) GetVulnerabilityCount(ctx *model.Context) (int, error)

func (*Client) HasAuthState

func (x *Client) HasAuthState(ctx *model.Context, state string, now int64) (bool, error)

func (*Client) Open

func (x *Client) Open(dbType, dbConfig string) error

func (*Client) PutPackages

func (x *Client) PutPackages(ctx *model.Context, packages []*ent.PackageRecord) ([]*ent.PackageRecord, error)

func (*Client) PutScan

func (x *Client) PutScan(ctx *model.Context, scan *ent.Scan, repo *ent.Repository, packages []*ent.PackageRecord) (*ent.Scan, error)

func (*Client) PutSession

func (x *Client) PutSession(ctx *model.Context, ssn *ent.Session) error

func (*Client) PutUser

func (x *Client) PutUser(ctx *model.Context, user *ent.User) (int, error)

func (*Client) PutVulnStatus

func (x *Client) PutVulnStatus(ctx *model.Context, repo *ent.Repository, status *ent.VulnStatus, userID int) (*ent.VulnStatus, error)

func (*Client) PutVulnerabilities

func (x *Client) PutVulnerabilities(ctx *model.Context, vulnerabilities []*ent.Vulnerability) error

func (*Client) SaveAuthState

func (x *Client) SaveAuthState(ctx *model.Context, state string, expiresAt int64) error

Auth

func (*Client) UnassignRepoLabel added in v0.1.4

func (x *Client) UnassignRepoLabel(ctx *model.Context, repoID int, labelID int) error

func (*Client) UpdateRepoLabel added in v0.1.4

func (x *Client) UpdateRepoLabel(ctx *model.Context, id int, req *model.RequestRepoLabel) error

func (*Client) UpdateSeverity added in v0.1.1

func (x *Client) UpdateSeverity(ctx *model.Context, id int, req *model.RequestSeverity) error

type Factory

type Factory func(dbType, dbConfig string) (Interface, error)

type Interface

type Interface interface {
	Open(dbType, dbConfig string) error
	Close() error

	CreateRepo(ctx *model.Context, repo *ent.Repository) (*ent.Repository, error)

	// Vulnerability
	PutVulnerabilities(ctx *model.Context, vulnerabilities []*ent.Vulnerability) error
	GetVulnerability(ctx *model.Context, id string) (*ent.Vulnerability, error)
	GetLatestVulnerabilities(ctx *model.Context, offset, limit int) ([]*ent.Vulnerability, error)
	GetVulnerabilityCount(ctx *model.Context) (int, error)

	// Severity
	CreateSeverity(ctx *model.Context, req *model.RequestSeverity) (*ent.Severity, error)
	DeleteSeverity(ctx *model.Context, id int) error
	GetSeverities(ctx *model.Context) ([]*ent.Severity, error)
	UpdateSeverity(ctx *model.Context, id int, req *model.RequestSeverity) error
	AssignSeverity(ctx *model.Context, vulnID string, id int) error

	PutPackages(ctx *model.Context, packages []*ent.PackageRecord) ([]*ent.PackageRecord, error)
	PutScan(ctx *model.Context, scan *ent.Scan, repo *ent.Repository, packages []*ent.PackageRecord) (*ent.Scan, error)
	PutVulnStatus(ctx *model.Context, repo *ent.Repository, status *ent.VulnStatus, userID int) (*ent.VulnStatus, error)
	GetVulnStatus(ctx *model.Context, repo *model.GitHubRepo) ([]*ent.VulnStatus, error)

	GetScan(ctx *model.Context, id string) (*ent.Scan, error)
	GetLatestScan(ctx *model.Context, branch model.GitHubBranch) (*ent.Scan, error)
	GetLatestScans(ctx *model.Context) ([]*ent.Scan, error)
	GetRepositories(ctx *model.Context) ([]*ent.Repository, error)
	GetRepositoriesWithVuln(ctx *model.Context, vulnID string) ([]*ent.Repository, error)
	GetRepository(ctx *model.Context, repo *model.GitHubRepo) (*ent.Repository, error)
	GetRepositoryScan(ctx *model.Context, req *model.GetRepoScanRequest) ([]*ent.Scan, error)

	// Repository Label
	CreateRepoLabel(ctx *model.Context, req *model.RequestRepoLabel) (*ent.RepoLabel, error)
	UpdateRepoLabel(ctx *model.Context, id int, req *model.RequestRepoLabel) error
	DeleteRepoLabel(ctx *model.Context, id int) error
	GetRepoLabels(ctx *model.Context) ([]*ent.RepoLabel, error)
	AssignRepoLabel(ctx *model.Context, repoID int, labelID int) error
	UnassignRepoLabel(ctx *model.Context, repoID int, labelID int) error

	// Auth
	SaveAuthState(ctx *model.Context, state string, expiresAt int64) error
	HasAuthState(ctx *model.Context, state string, now int64) (bool, error)
	GetUser(ctx *model.Context, userID int) (*ent.User, error)
	PutUser(ctx *model.Context, user *ent.User) (int, error)
	PutSession(ctx *model.Context, ssn *ent.Session) error
	GetSession(ctx *model.Context, ssnID string, now int64) (*ent.Session, error)
	DeleteSession(ctx *model.Context, ssnID string) error
}

type ScanResult

type ScanResult struct {
	Repo            *ent.Repository
	Scan            *ent.Scan
	Packages        []*ent.PackageRecord
	Vulnerabilities []*ent.Vulnerability
}

Jump to

Keyboard shortcuts

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