model

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VulnAdded vulnChangeType = iota
	VulnDeleted
	VulnRemained
)
View Source
const (
	ContextKeyLogger = "logger"
)
View Source
const (
	Version = "0.0.1"
)

Variables

View Source
var (
	ErrDatabaseUnexpected   = goerr.New("database failure")
	ErrDatabaseInvalidInput = goerr.New("invalid input for database")
	ErrItemNotFound         = goerr.New("item not found")
	ErrInvalidSystemValue   = goerr.New("invalid system value")

	ErrInvalidGitHubData = goerr.New("invalid github data")

	ErrInvalidInput          = goerr.New("invalid input data")
	ErrAuthenticationFailed  = goerr.New("authentication failed")
	ErrNotAuthenticated      = goerr.New("not authenticated request")
	ErrNotAuthorized         = goerr.New("not authorized request")
	ErrUserNotFound          = goerr.New("user not found")
	ErrVulnerabilityNotFound = goerr.New("vulnerability not found")
	ErrInvalidWebhookData    = goerr.New("invalid webhook data")
	ErrGitHubAPI             = goerr.New("github API returns unexpected response")

	// Rule error
	ErrInvalidPolicyResult = goerr.New("invalid rule result")
)

Functions

func TrivyReportToEnt

func TrivyReportToEnt(report *TrivyReport, now time.Time) (pkgList []*ent.PackageRecord, vulnList []*ent.Vulnerability)

Types

type Config

type Config struct {
	FrontendURL string

	DisableFrontend      bool
	DisableWebhookGitHub bool
	DisableWebhookTrivy  bool

	ServerAddr string
	ServerPort int

	GitHubWebhookSecret string `zlog:"secret"`

	SentryDSN string
	SentryEnv string
}

type Context

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

func NewContext

func NewContext() *Context

func NewContextWith

func NewContextWith(ctx context.Context) *Context

func (*Context) Deadline

func (x *Context) Deadline() (deadline time.Time, ok bool)

func (*Context) Done

func (x *Context) Done() <-chan struct{}

func (*Context) Err

func (x *Context) Err() error

func (*Context) Log

func (x *Context) Log() *zlog.LogEntity

Logging feature

func (*Context) Value

func (x *Context) Value(key interface{}) interface{}

func (*Context) With

func (x *Context) With(key string, value interface{}) *zlog.LogEntity

type GetRepoScanRequest added in v0.1.4

type GetRepoScanRequest struct {
	GitHubRepo
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

type GitHubBranch

type GitHubBranch struct {
	GitHubRepo
	Branch string `json:"branch"`
}

type GitHubCheckResult added in v0.1.2

type GitHubCheckResult struct {
	Conclusion string   `json:"conclusion"`
	Messages   []string `json:"messages"`
}

type GitHubRepo

type GitHubRepo struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

type GitHubToken

type GitHubToken struct {
	UserID                string
	AccessToken           string `json:"access_token"`
	ExpiresIn             int64  `json:"expires_in"`
	RefreshToken          string `json:"refresh_token"`
	RefreshTokenExpiresIn int64  `json:"refresh_token_expires_in"`
	Scope                 string `json:"scope"`
	TokenType             string `json:"token_type"`
}

type Package added in v0.1.2

type Package struct {
	ent.PackageRecord
	Vulnerabilities []*Vulnerability `json:"vulnerabilities,omitempty"`

	// To remove "edges" field in JSON
	Edges *struct{} `json:"edges,omitempty"`
}

type PackageSource added in v0.1.2

type PackageSource struct {
	Source   string     `json:"source"`
	Packages []*Package `json:"packages"`
}

type PushTrivyResultRequest added in v0.1.10

type PushTrivyResultRequest struct {
	Target ScanTarget
	Report TrivyReport
}

func (*PushTrivyResultRequest) IsValid added in v0.1.10

func (x *PushTrivyResultRequest) IsValid() error

type Report

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

func MakeReport

func MakeReport(scanID string, changes VulnChanges, db *VulnStatusDB, url string) *Report

func (*Report) NothingToNotify

func (x *Report) NothingToNotify(githubEvent string) bool

func (*Report) Summary added in v0.1.2

func (x *Report) Summary() string

func (*Report) ToMarkdown added in v0.1.2

func (x *Report) ToMarkdown() string

type Repository added in v0.1.5

type Repository struct {
	GitHubBranch
	Labels        []string `json:"labels"`
	DefaultBranch string   `json:"default_branch"`
}

type RequestRepoLabel added in v0.1.4

type RequestRepoLabel struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Color       string `json:"color"`
}

func (*RequestRepoLabel) IsValid added in v0.1.4

func (x *RequestRepoLabel) IsValid() error

type RequestSeverity added in v0.1.1

type RequestSeverity struct {
	Label string
	Color string
}

func (*RequestSeverity) IsValid added in v0.1.1

func (x *RequestSeverity) IsValid() error

type RespVulnerability

type RespVulnerability struct {
	Vulnerability *ent.Vulnerability `json:"vulnerability"`
	Affected      []*ent.Repository  `json:"affected"`
}

type ScanReport added in v0.1.5

type ScanReport struct {
	Repo     Repository       `json:"repo"`
	CommitID string           `json:"commit_id"`
	Sources  []*PackageSource `json:"sources"`
}

func NewScanReport added in v0.1.5

func NewScanReport(scan *ent.Scan, statuses []*ent.VulnStatus, now int64) *ScanReport

type ScanRepositoryRequest

type ScanRepositoryRequest struct {
	ScanTarget
	InstallID     int64
	PullReqNumber *int
	PullReqAction string
}

type ScanTarget

type ScanTarget struct {
	GitHubBranch
	CommitID     string
	UpdatedAt    int64
	RequestedAt  int64
	URL          string
	TargetBranch string
}

type SourceChanges

type SourceChanges struct {
	Added    VulnChanges
	Deleted  VulnChanges
	Remained VulnChanges
}

type TrivyReport

type TrivyReport report.Report

type UpdateVulnStatusRequest

type UpdateVulnStatusRequest struct {
	GitHubRepo
	UserID int
	ent.VulnStatus
}

type VulnChanges

type VulnChanges []*vulnChange

func DiffVulnRecords

func DiffVulnRecords(oldPkgs, newPkgs []*ent.PackageRecord) VulnChanges

func (VulnChanges) FilterBySource

func (x VulnChanges) FilterBySource(src string) VulnChanges

func (VulnChanges) FilterByType

func (x VulnChanges) FilterByType(t vulnChangeType) VulnChanges

func (VulnChanges) Qualified

func (x VulnChanges) Qualified(db *VulnStatusDB) VulnChanges

func (VulnChanges) Sources

func (x VulnChanges) Sources() []string

type VulnRecord

type VulnRecord struct {
	Pkg  *ent.PackageRecord
	Vuln *ent.Vulnerability
}

type VulnStatusDB

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

func NewVulnStatusDB

func NewVulnStatusDB(statuses []*ent.VulnStatus, now int64) *VulnStatusDB

func (*VulnStatusDB) IsQualified

func (x *VulnStatusDB) IsQualified(v *VulnRecord) bool

func (*VulnStatusDB) Lookup added in v0.1.2

func (x *VulnStatusDB) Lookup(pkg *ent.PackageRecord, vulnID string) *ent.VulnStatus

type Vulnerability added in v0.1.2

type Vulnerability struct {
	ent.Vulnerability
	Status         *ent.VulnStatus `json:"status,omitempty"`
	CustomSeverity string          `json:"custom_severity"`

	// To remove "edges" field in JSON
	Edges *struct{} `json:"edges,omitempty"`
}

Jump to

Keyboard shortcuts

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