db

package
v97.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const FailedFetchThreshold = 3

Variables

This section is empty.

Functions

func NewCommitRepository

func NewCommitRepository(db *gorm.DB) *commitRepository

func NewDSN

func NewDSN(username, password, dbName, hostname string, port int, serverName string, certificate tls.Certificate, caCertPool *x509.CertPool) string

func NewFetchRepository

func NewFetchRepository(db *gorm.DB) *fetchRepository

func NewRepositoryRepository

func NewRepositoryRepository(db *gorm.DB) *repositoryRepository

Types

type ActiveScan

type ActiveScan interface {
	RecordCredential(Credential)
	Finish() error
}

type Branch

type Branch struct {
	Model

	RepositoryID uint

	Name            string
	CredentialCount uint
}

type BranchCredentialCount

type BranchCredentialCount struct {
	Owner string
	Name  string

	Branch string

	CredentialCount int
}

type BranchRepository

type BranchRepository interface {
	GetBranches(repository Repository) ([]Branch, error)
	UpdateBranches(repository Repository, branches []Branch) error

	GetCredentialCountByOwner() ([]OwnerCredentialCount, error)
	GetCredentialCountForOwner(owner string) ([]RepositoryCredentialCount, error)
	GetCredentialCountForRepo(owner string, repo string) ([]BranchCredentialCount, error)
}

func NewBranchRepository

func NewBranchRepository(db *gorm.DB) BranchRepository

type Commit

type Commit struct {
	Model
	Owner      string
	Repository string
	SHA        string
}

type CommitRepository

type CommitRepository interface {
	RegisterCommit(logger lager.Logger, commit *Commit) error
	IsCommitRegistered(logger lager.Logger, sha string) (bool, error)
	IsRepoRegistered(logger lager.Logger, owner, repo string) (bool, error)
}

type Credential

type Credential struct {
	Model

	Scan   Scan
	ScanID uint

	Owner      string
	Repository string
	SHA        string
	Path       string
	LineNumber int
	MatchStart int
	MatchEnd   int
	Private    bool
}

func (*Credential) Hash

func (c *Credential) Hash() string

type CredentialRepository

type CredentialRepository interface {
	ForScanWithID(int) ([]Credential, error)
	UniqueSHAsForRepoAndRulesVersion(Repository, int) ([]string, error)
	CredentialReported(cred *Credential) (bool, error)
}

func NewCredentialRepository

func NewCredentialRepository(db *gorm.DB) CredentialRepository

type Fetch

type Fetch struct {
	Model
	Repository   *Repository
	RepositoryID uint

	Path    string
	Changes []byte
}

type FetchRepository

type FetchRepository interface {
	RegisterFetch(lager.Logger, *Fetch) error
}

type Model

type Model struct {
	ID        uint `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type OwnerCredentialCount

type OwnerCredentialCount struct {
	Owner           string
	CredentialCount int
}

type PriorScan

type PriorScan struct {
	ID          int
	Branch      string
	StartSHA    string
	StopSHA     string
	Repository  string
	Owner       string
	Credentials []Credential
}

type Repository

type Repository struct {
	Model

	Cloned bool

	Name          string
	Owner         string
	Path          string
	SSHURL        string `gorm:"column:ssh_url"`
	Private       bool
	DefaultBranch string

	FailedFetches int `gorm:"column:failed_fetches"`
	Disabled      bool
}

type RepositoryCredentialCount

type RepositoryCredentialCount struct {
	Owner   string
	Name    string
	Private bool

	CredentialCount int
}

type RepositoryRepository

type RepositoryRepository interface {
	Create(*Repository) error

	Update(*Repository) error

	Delete(*Repository) error

	Find(owner, name string) (Repository, bool, error)
	MustFind(owner, name string) (Repository, error)

	All() ([]Repository, error)
	Active() ([]Repository, error)
	AllForOrganization(string) ([]Repository, error)
	NotScannedWithVersion(int) ([]Repository, error)

	MarkAsCloned(owner, name, path string) error
	Reenable(owner, name string) error
	RegisterFailedFetch(lager.Logger, *Repository) error
}

type Scan

type Scan struct {
	Model

	Type         string
	RulesVersion int

	ScanStart time.Time
	ScanEnd   time.Time

	Branch   string
	StartSHA string
	StopSHA  string

	Repository   *Repository
	RepositoryID *uint

	Credentials []Credential
}

type ScanRepository

type ScanRepository interface {
	Start(lager.Logger, string, string, string, string, *Repository) ActiveScan
	ScansNotYetRunWithVersion(lager.Logger, int) ([]PriorScan, error)
}

func NewScanRepository

func NewScanRepository(db *gorm.DB, clock clock.Clock) ScanRepository

type StatsRepository

type StatsRepository interface {
	RepositoryCount() (int, error)
	DisabledRepositoryCount() (int, error)
	UnclonedRepositoryCount() (int, error)
	CredentialCount() (int, error)
	FetchCount() (int, error)
}

func NewStatsRepository

func NewStatsRepository(db *gorm.DB) StatsRepository

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