storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestNoteID = "CVE-1999-0710"
)

Variables

This section is empty.

Functions

func CreateSourceString

func CreateSourceString(user, password, host, dbName, SSLMode string) string

CreateSourceString generates DB source path.

func TestNote

func TestNote(pID string) *pb.Note

func TestOccurrence

func TestOccurrence(pID, noteName string) *pb.Occurrence

Types

type EmbeddedStore

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

EmbeddedStore is a storage solution for Grafeas based on boltdb

func NewEmbeddedStore

func NewEmbeddedStore(config *config.EmbeddedStoreConfig) *EmbeddedStore

NewEmbeddedStore creates a embeddedS store with initialized filesystem

func (*EmbeddedStore) BatchCreateNotes

func (m *EmbeddedStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*pb.Note) ([]*pb.Note, []error)

BatchCreateNotes batch creates the specified notes in embedded store.

func (*EmbeddedStore) BatchCreateOccurrences

func (m *EmbeddedStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*pb.Occurrence) ([]*pb.Occurrence, []error)

BatchCreateOccurrence batch creates the specified occurrences in embedded store.

func (*EmbeddedStore) CreateNote

func (m *EmbeddedStore) CreateNote(ctx context.Context, pID, nID, uID string, n *pb.Note) (*pb.Note, error)

CreateNote creates the specified note in embedded store.

func (*EmbeddedStore) CreateOccurrence

func (m *EmbeddedStore) CreateOccurrence(ctx context.Context, pID, uID string, o *pb.Occurrence) (*pb.Occurrence, error)

CreateOccurrence creates the specified occurrence in embedded store.

func (*EmbeddedStore) CreateProject

func (m *EmbeddedStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)

CreateProject creates the specified project in embedded store.

func (*EmbeddedStore) DeleteNote

func (m *EmbeddedStore) DeleteNote(ctx context.Context, pID, nID string) error

DeleteNote deletes the specified note in embedded store.

func (*EmbeddedStore) DeleteOccurrence

func (m *EmbeddedStore) DeleteOccurrence(ctx context.Context, pID, oID string) error

DeleteOccurrence deletes the specified occurrence in embedded store.

func (*EmbeddedStore) DeleteProject

func (m *EmbeddedStore) DeleteProject(ctx context.Context, pID string) error

DeleteProject deletes the specified project from embedded store.

func (*EmbeddedStore) GetNote

func (m *EmbeddedStore) GetNote(ctx context.Context, pID, nID string) (*pb.Note, error)

GetNote gets the specified note from embedded store.

func (*EmbeddedStore) GetOccurrence

func (m *EmbeddedStore) GetOccurrence(ctx context.Context, pID, oID string) (*pb.Occurrence, error)

GetOccurrence gets the specified occurrence from embedded store.

func (*EmbeddedStore) GetOccurrenceNote

func (m *EmbeddedStore) GetOccurrenceNote(ctx context.Context, pID, oID string) (*pb.Note, error)

GetOccurrenceNote gets the note for the specified occurrence from embedded store.

func (*EmbeddedStore) GetProject

func (m *EmbeddedStore) GetProject(ctx context.Context, pID string) (*prpb.Project, error)

GetProject gets the specified project from embedded store.

func (*EmbeddedStore) GetVulnerabilityOccurrencesSummary

func (m *EmbeddedStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*pb.VulnerabilityOccurrencesSummary, error)

GetVulnerabilityOccurrencesSummary gets a summary of vulnerability occurrences from storage.

func (*EmbeddedStore) ListNoteOccurrences

func (m *EmbeddedStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)

ListNoteOccurrences returns up to pageSize number of occurrences on the note for the project beginning at pageToken, or from start if pageToken is empty.

func (*EmbeddedStore) ListNotes

func (m *EmbeddedStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Note, string, error)

ListNotes returns up to pageSize number of notes for the project beginning at pageToken, or from start if pageToken is the empty string.

func (*EmbeddedStore) ListOccurrences

func (m *EmbeddedStore) ListOccurrences(ctx context.Context, pID, filters, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)

ListOccurrences returns up to pageSize number of occurrences for this project (pID) beginning at pageToken (or from start if pageToken is the empty string).

func (*EmbeddedStore) ListProjects

func (m *EmbeddedStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)

ListProjects returns up to pageSize number of projects beginning at pageToken, or from start if pageToken is the empty string.

func (*EmbeddedStore) UpdateNote

func (m *EmbeddedStore) UpdateNote(ctx context.Context, pID, nID string, n *pb.Note, mask *fieldmaskpb.FieldMask) (*pb.Note, error)

UpdateNote updates the specified note in embedded store.

func (*EmbeddedStore) UpdateOccurrence

func (m *EmbeddedStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *pb.Occurrence, mask *fieldmaskpb.FieldMask) (*pb.Occurrence, error)

UpdateOccurrence updates the specified occurrence in embedded store.

type MemStore

type MemStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MemStore is an in-memory storage solution for Grafeas

func NewMemStore

func NewMemStore() *MemStore

NewMemStore creates a MemStore with all maps initialized.

func (*MemStore) BatchCreateNotes

func (m *MemStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*gpb.Note) ([]*gpb.Note, []error)

BatchCreateNotes batch creates the specified notes in memstore.

func (*MemStore) BatchCreateOccurrences

func (m *MemStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*gpb.Occurrence) ([]*gpb.Occurrence, []error)

BatchCreateOccurrence batch creates the specified occurrences in memstore.

func (*MemStore) CreateNote

func (m *MemStore) CreateNote(ctx context.Context, pID, nID, uID string, n *gpb.Note) (*gpb.Note, error)

CreateNote creates the specified note in memstore.

func (*MemStore) CreateOccurrence

func (m *MemStore) CreateOccurrence(ctx context.Context, pID, uID string, o *gpb.Occurrence) (*gpb.Occurrence, error)

CreateOccurrence creates the specified occurrence in memstore.

func (*MemStore) CreateProject

func (m *MemStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)

CreateProject creates the specified project in memstore.

func (*MemStore) DeleteNote

func (m *MemStore) DeleteNote(ctx context.Context, pID, nID string) error

DeleteNote deletes the specified note in memstore.

func (*MemStore) DeleteOccurrence

func (m *MemStore) DeleteOccurrence(ctx context.Context, pID, oID string) error

DeleteOccurrence deletes the specified occurrence in memstore.

func (*MemStore) DeleteProject

func (m *MemStore) DeleteProject(ctx context.Context, pID string) error

DeleteProject deletes the specified project from memstore.

func (*MemStore) GetNote

func (m *MemStore) GetNote(ctx context.Context, pID, nID string) (*gpb.Note, error)

GetNote gets the specified note from memstore.

func (*MemStore) GetOccurrence

func (m *MemStore) GetOccurrence(ctx context.Context, pID, oID string) (*gpb.Occurrence, error)

GetOccurrence gets the specified occurrence from memstore.

func (*MemStore) GetOccurrenceNote

func (m *MemStore) GetOccurrenceNote(ctx context.Context, pID, oID string) (*gpb.Note, error)

GetOccurrenceNote gets the note for the specified occurrence from memstore.

func (*MemStore) GetProject

func (m *MemStore) GetProject(ctx context.Context, pID string) (*prpb.Project, error)

GetProject gets the specified project from memstore.

func (*MemStore) GetVulnerabilityOccurrencesSummary

func (m *MemStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*gpb.VulnerabilityOccurrencesSummary, error)

GetVulnerabilityOccurrencesSummary gets a summary of vulnerability occurrences from storage.

func (*MemStore) ListNoteOccurrences

func (m *MemStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*gpb.Occurrence, string, error)

ListNoteOccurrences returns up to pageSize number of occurrences on the note for the project beginning at pageToken, or from start if pageToken is empty.

func (*MemStore) ListNotes

func (m *MemStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*gpb.Note, string, error)

ListNotes returns up to pageSize number of notes for the project pID beginning at pageToken, or from start if pageToken is the empty string.

func (*MemStore) ListOccurrences

func (m *MemStore) ListOccurrences(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*gpb.Occurrence, string, error)

ListOccurrences returns up to pageSize number of occurrences for this project beginning at pageToken, or from start if pageToken is the empty string.

func (*MemStore) ListProjects

func (m *MemStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)

ListProjects returns up to pageSize number of projects beginning at pageToken, or from start if pageToken is the empty string.

func (*MemStore) UpdateNote

func (m *MemStore) UpdateNote(ctx context.Context, pID, nID string, n *gpb.Note, mask *fieldmaskpb.FieldMask) (*gpb.Note, error)

UpdateNote updates the specified note in memstore.

func (*MemStore) UpdateOccurrence

func (m *MemStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *gpb.Occurrence, mask *fieldmaskpb.FieldMask) (*gpb.Occurrence, error)

UpdateOccurrence updates the specified occurrence in memstore.

type PgSQLStore

type PgSQLStore struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewPgSQLStore

func NewPgSQLStore(config *config.PgSQLConfig) *PgSQLStore

func (*PgSQLStore) BatchCreateNotes

func (pg *PgSQLStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*pb.Note) ([]*pb.Note, []error)

BatchCreateNotes batch creates the specified notes in memstore.

func (*PgSQLStore) BatchCreateOccurrences

func (pg *PgSQLStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*pb.Occurrence) ([]*pb.Occurrence, []error)

BatchCreateOccurrence batch creates the specified occurrences in PostreSQL.

func (*PgSQLStore) CreateNote

func (pg *PgSQLStore) CreateNote(ctx context.Context, pID, nID, uID string, n *pb.Note) (*pb.Note, error)

CreateNote adds the specified note

func (*PgSQLStore) CreateOccurrence

func (pg *PgSQLStore) CreateOccurrence(ctx context.Context, pID, uID string, o *pb.Occurrence) (*pb.Occurrence, error)

CreateOccurrence adds the specified occurrence

func (*PgSQLStore) CreateProject

func (pg *PgSQLStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)

CreateProject adds the specified project to the store

func (*PgSQLStore) DeleteNote

func (pg *PgSQLStore) DeleteNote(ctx context.Context, pID, nID string) error

DeleteNote deletes the note with the given pID and nID

func (*PgSQLStore) DeleteOccurrence

func (pg *PgSQLStore) DeleteOccurrence(ctx context.Context, pID, oID string) error

DeleteOccurrence deletes the occurrence with the given pID and oID

func (*PgSQLStore) DeleteProject

func (pg *PgSQLStore) DeleteProject(ctx context.Context, pID string) error

DeleteProject deletes the project with the given pID from the store

func (*PgSQLStore) GetNote

func (pg *PgSQLStore) GetNote(ctx context.Context, pID, nID string) (*pb.Note, error)

GetNote returns the note with project (pID) and note ID (nID)

func (*PgSQLStore) GetOccurrence

func (pg *PgSQLStore) GetOccurrence(ctx context.Context, pID, oID string) (*pb.Occurrence, error)

GetOccurrence returns the occurrence with pID and oID

func (*PgSQLStore) GetOccurrenceNote

func (pg *PgSQLStore) GetOccurrenceNote(ctx context.Context, pID, oID string) (*pb.Note, error)

GetOccurrenceNote gets the note for the specified occurrence from PostgreSQL.

func (*PgSQLStore) GetProject

func (pg *PgSQLStore) GetProject(ctx context.Context, pID string) (*prpb.Project, error)

GetProject returns the project with the given pID from the store

func (*PgSQLStore) GetVulnerabilityOccurrencesSummary

func (pg *PgSQLStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*pb.VulnerabilityOccurrencesSummary, error)

GetVulnerabilityOccurrencesSummary gets a summary of vulnerability occurrences from storage.

func (*PgSQLStore) ListNoteOccurrences

func (pg *PgSQLStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)

ListNoteOccurrences returns up to pageSize number of occcurrences on the particular note (nID) for this project (pID) projects beginning at pageToken (or from start if pageToken is the empty string).

func (*PgSQLStore) ListNotes

func (pg *PgSQLStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Note, string, error)

ListNotes returns up to pageSize number of notes for this project (pID) beginning at pageToken (or from start if pageToken is the empty string).

func (*PgSQLStore) ListOccurrences

func (pg *PgSQLStore) ListOccurrences(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)

ListOccurrences returns up to pageSize number of occurrences for this project beginning at pageToken, or from start if pageToken is the empty string.

func (*PgSQLStore) ListProjects

func (pg *PgSQLStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)

ListProjects returns up to pageSize number of projects beginning at pageToken (or from start if pageToken is the empty string).

func (*PgSQLStore) UpdateNote

func (pg *PgSQLStore) UpdateNote(ctx context.Context, pID, nID string, n *pb.Note, mask *fieldmaskpb.FieldMask) (*pb.Note, error)

UpdateNote updates the existing note with the given pID and nID

func (*PgSQLStore) UpdateOccurrence

func (pg *PgSQLStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *pb.Occurrence, mask *fieldmaskpb.FieldMask) (*pb.Occurrence, error)

UpdateOccurrence updates the existing occurrence with the given projectID and occurrenceID

Jump to

Keyboard shortcuts

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