storage

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ElasticsearchStorageTypeProviderCreator

func ElasticsearchStorageTypeProviderCreator(newES newElasticsearchStorageFunc, logger *zap.Logger) registerStorageTypeProviderFunc

ElasticsearchStorageTypeProviderCreator takes a function that returns a new instance of ElasticsearchStorage, when called later with the parsed Grafeas config file into config.ElasticsearchConfig. It returns a function that is given to Grafeas to register the Elasticsearch storage type provider. This allows for the ability to still inject different ElasticsearchStorage configurations, e.g. testing. This is done this way because we do not get access to the parsed config until after Grafeas server is started and registers the storage type provider.

Types

type ElasticsearchStorage

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

func NewElasticsearchStorage

func NewElasticsearchStorage(
	logger *zap.Logger,
	client esutil.Client,
	filterer filtering.Filterer,
	config *config.ElasticsearchConfig,
	indexManager indexmanager.IndexManager) *ElasticsearchStorage

func (*ElasticsearchStorage) BatchCreateNotes

func (es *ElasticsearchStorage) BatchCreateNotes(ctx context.Context, projectId, uID string, notesWithNoteIds map[string]*pb.Note) ([]*pb.Note, []error)

BatchCreateNotes batch creates the specified notes in elasticsearch.

func (*ElasticsearchStorage) BatchCreateOccurrences

func (es *ElasticsearchStorage) BatchCreateOccurrences(ctx context.Context, projectId string, uID string, occurrences []*pb.Occurrence) ([]*pb.Occurrence, []error)

BatchCreateOccurrences batch creates the specified occurrences in Elasticsearch. This method uses the ES "_bulk" API: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html This method will return all of the occurrences that were successfully created, and all of the errors that were encountered (if any)

func (*ElasticsearchStorage) CreateNote

func (es *ElasticsearchStorage) CreateNote(ctx context.Context, projectId, noteId, uID string, note *pb.Note) (*pb.Note, error)

CreateNote adds the specified note

func (*ElasticsearchStorage) CreateOccurrence

func (es *ElasticsearchStorage) CreateOccurrence(ctx context.Context, projectId, userID string, occurrence *pb.Occurrence) (*pb.Occurrence, error)

CreateOccurrence adds the specified occurrence to Elasticsearch

func (*ElasticsearchStorage) CreateProject

func (es *ElasticsearchStorage) CreateProject(ctx context.Context, projectId string, project *prpb.Project) (*prpb.Project, error)

CreateProject creates a project document within the project index, along with two indices that can be used to store notes and occurrences. Additional metadata is attached to the newly created indices to help identify them as part of a Grafeas project

func (*ElasticsearchStorage) DeleteNote

func (es *ElasticsearchStorage) DeleteNote(ctx context.Context, projectId, noteId string) error

DeleteNote deletes the note with the given pID and nID

func (*ElasticsearchStorage) DeleteOccurrence

func (es *ElasticsearchStorage) DeleteOccurrence(ctx context.Context, projectId, occurrenceId string) error

DeleteOccurrence deletes the occurrence with the given projectId and occurrenceId

func (*ElasticsearchStorage) DeleteProject

func (es *ElasticsearchStorage) DeleteProject(ctx context.Context, projectId string) error

DeleteProject deletes the project with the given projectId from Elasticsearch Note that this will always return a 500 due to a bug in Grafeas

func (*ElasticsearchStorage) GetNote

func (es *ElasticsearchStorage) GetNote(ctx context.Context, projectId, noteId string) (*pb.Note, error)

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

func (*ElasticsearchStorage) GetOccurrence

func (es *ElasticsearchStorage) GetOccurrence(ctx context.Context, projectId, occurrenceId string) (*pb.Occurrence, error)

GetOccurrence returns the occurrence with name projects/${projectId}/occurrences/${occurrenceId} from Elasticsearch

func (*ElasticsearchStorage) GetOccurrenceNote

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

GetOccurrenceNote gets the note for the specified occurrence from PostgreSQL.

func (*ElasticsearchStorage) GetProject

func (es *ElasticsearchStorage) GetProject(ctx context.Context, projectId string) (*prpb.Project, error)

GetProject returns the project with the given projectId from Elasticsearch

func (*ElasticsearchStorage) GetVulnerabilityOccurrencesSummary

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

GetVulnerabilityOccurrencesSummary gets a summary of vulnerability occurrences from storage.

func (*ElasticsearchStorage) Initialize added in v0.5.0

func (es *ElasticsearchStorage) Initialize(ctx context.Context) error

func (*ElasticsearchStorage) ListNoteOccurrences

func (es *ElasticsearchStorage) ListNoteOccurrences(ctx context.Context, projectID, nID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)

ListNoteOccurrences is...

func (*ElasticsearchStorage) ListNotes

func (es *ElasticsearchStorage) ListNotes(ctx context.Context, projectId, 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 (*ElasticsearchStorage) ListOccurrences

func (es *ElasticsearchStorage) ListOccurrences(ctx context.Context, projectId, 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 (*ElasticsearchStorage) ListProjects

func (es *ElasticsearchStorage) 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 (*ElasticsearchStorage) UpdateNote

func (es *ElasticsearchStorage) 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 (*ElasticsearchStorage) UpdateOccurrence

func (es *ElasticsearchStorage) UpdateOccurrence(ctx context.Context, projectId, occurrenceId string, o *pb.Occurrence, mask *fieldmaskpb.FieldMask) (*pb.Occurrence, error)

UpdateOccurrence updates the existing occurrence with the given projectId and occurrenceId

Directories

Path Synopsis
esutilfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
filteringfakes
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