storage

package
v0.0.0-...-9651868 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoteOccurrencesMaxID = `` /* 200-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func PostgresqlStorageTypeProvider

func PostgresqlStorageTypeProvider(_ string, ci *config.StorageConfiguration) (*storage.Storage, error)

PostgresqlStorageTypeProvider creates and initializes a new grafeas v1beta1 storage compatible PgSQL store based on the specified config.

Types

type Config

type Config struct {
	Host string `json:"host"`
	Port int    `json:"port"`
	// DBName has to alrady exist and can be accessed by User.
	DBName   string `json:"db_name"`
	User     string `json:"user"`
	Password string `json:"password"`
	// Valid sslmodes: disable, allow, prefer, require, verify-ca, verify-full.
	// See https://www.postgresql.org/docs/current/static/libpq-connect.html for details
	SSLMode     string `json:"ssl_mode"`
	SSLRootCert string `json:"ssl_root_cert"`
	// PaginationKey is a 32-bit URL-safe base64 key used to encrypt pagination tokens.
	// If one is not provided, it will be generated.
	// Multiple grafeas instances in the same cluster need the same value,
	// and the reason follows:
	// A client sends all requests to a unified load balancer,
	// but it can contain multiple Grafeas instances.
	// Consequently, if they do not share the same pagination key,
	// the encrypted page returned by one instance cannot be successfully decrypted by another instance.
	// As a result, if requests are routed to different Grafeas instances, pagination will be broken.
	PaginationKey string `json:"pagination_key"`
}

Config is the configuration for PostgreSQL store. json tags are required because config.ConvertGenericConfigToSpecificType internally uses json package.

type FilterSQL

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

func (*FilterSQL) ParseFilter

func (fs *FilterSQL) ParseFilter(filter string) string

ParseFilter parses the incoming filter and returns a formatted SQL query.

type PgSQLStore

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

PgSQLStore provides functionalities to use PostgreSQL DB as a data store.

func NewPgSQLStore

func NewPgSQLStore(config *Config) (*PgSQLStore, error)

NewPgSQLStore creates a new PgSQL store based on the passed-in config.

func NewStoreWithCustomConnector

func NewStoreWithCustomConnector(connector driver.Connector, paginationKey string) (*PgSQLStore, error)

NewStoreWithCustomConnector creates a new PgSQL store using the custom connector.

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)

BatchCreateOccurrences 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 occurrences 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