store

package
v1.3.27 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(pDialect, connectionString string, logger log.Logger, logMode bool, defaults map[string][]string) (api.VulcanitoStore, error)

NewDB returns a connection to a Postgres instance

Types

type AssetsReader added in v1.1.4

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

AssetsReader reads all the assets stored in Vulcan using pages with a configurable size.

func (*AssetsReader) Assets added in v1.1.4

func (a *AssetsReader) Assets() []*api.Asset

Assets returns the assets produced by the last call to *AssetsReader.Read.

func (*AssetsReader) Close added in v1.1.4

func (a *AssetsReader) Close() error

Close closes the reader and unlocks the tables that were locked when it was created.

func (*AssetsReader) Err added in v1.1.4

func (a *AssetsReader) Err() error

Err returns the error produced by the last call to *AssetsReader.Read, returns nil if the last call didn't produce any error.

func (*AssetsReader) Read added in v1.1.4

func (a *AssetsReader) Read() bool

Read returns the next page of the assets according to the page size of the *AssetsReader. Returns true if the read operation was successful, in that case the assets can be retrieved by calling *AssetsReader.Assets.

type DefaultEntities

type DefaultEntities map[string][]string

DefaultEntities that may be used accross the API NOTE: This is a map to allow for testing without circular dependencies in the testutils package

type Store added in v1.1.4

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

Store provides access to the storage layer of the Vulcan API.

func NewStore added in v1.1.4

func NewStore(pDialect, connectionString string, logger log.Logger, logMode bool, defaults map[string][]string) (Store, error)

NewStore returns an initialized Vulcan Store.

func (Store) Close added in v1.1.4

func (db Store) Close() error

Close close vulcanitoStore db connection

func (Store) CountAssetsInGroups added in v1.1.4

func (db Store) CountAssetsInGroups(teamID string, groupIDs []string) (int, error)

func (Store) CreateAsset added in v1.1.4

func (db Store) CreateAsset(a api.Asset, groups []api.Group) (*api.Asset, error)

CreateAsset persists an asset in the database along with its annotations. It receives an asset and an array of groups. The asset will be associated with all groups from that array.

func (Store) CreateAssetAnnotations added in v1.1.4

func (db Store) CreateAssetAnnotations(teamID string, assetID string, annotations []*api.AssetAnnotation) ([]*api.AssetAnnotation, error)

CreateAssetAnnotations assign new annotations to a given asset belonging to a given team.

func (Store) CreateAssets added in v1.1.4

func (db Store) CreateAssets(assets []api.Asset, groups []api.Group) ([]api.Asset, error)

func (Store) CreateChecktypeSetting added in v1.1.4

func (db Store) CreateChecktypeSetting(setting api.ChecktypeSetting) (*api.ChecktypeSetting, error)

func (Store) CreateFindingOverwrite added in v1.1.4

func (db Store) CreateFindingOverwrite(findingOverwrite api.FindingOverwrite) error

func (Store) CreateGroup added in v1.1.4

func (db Store) CreateGroup(group api.Group) (*api.Group, error)

func (Store) CreatePolicy added in v1.1.4

func (db Store) CreatePolicy(policy api.Policy) (*api.Policy, error)

func (Store) CreateProgram added in v1.1.4

func (db Store) CreateProgram(program api.Program, teamID string) (*api.Program, error)

func (Store) CreateTeam added in v1.1.4

func (db Store) CreateTeam(team api.Team, ownerEmail string) (*api.Team, error)

CreateTeam inserts a new team in the database and includes the current user as an owner

func (Store) CreateTeamMember added in v1.1.4

func (db Store) CreateTeamMember(teamMember api.UserTeam) (*api.UserTeam, error)

func (Store) CreateUser added in v1.1.4

func (db Store) CreateUser(user api.User) (*api.User, error)

CreateUser inserts a new user in the database

func (Store) CreateUserIfNotExists added in v1.1.4

func (db Store) CreateUserIfNotExists(userData saml.UserData) error

CreateUserIfNotExists ...

func (Store) DeleteAllAssets added in v1.1.4

func (db Store) DeleteAllAssets(teamID string) error

func (Store) DeleteAllOutbox added in v1.1.4

func (db Store) DeleteAllOutbox() error

CleanOutbox deletes of the records in the outbox table.

func (Store) DeleteAsset added in v1.1.4

func (db Store) DeleteAsset(asset api.Asset) error

func (Store) DeleteAssetAnnotations added in v1.1.4

func (db Store) DeleteAssetAnnotations(teamID string, assetID string, annotations []*api.AssetAnnotation) error

DeleteAssetAnnotations deletes the given annotations belonging to the given asset and team.

func (Store) DeleteChecktypeSetting added in v1.1.4

func (db Store) DeleteChecktypeSetting(checktypeSettingID string) error

func (Store) DeleteGroup added in v1.1.4

func (db Store) DeleteGroup(group api.Group) error

func (Store) DeletePolicy added in v1.1.4

func (db Store) DeletePolicy(policy api.Policy) error

func (Store) DeleteProgram added in v1.1.4

func (db Store) DeleteProgram(program api.Program, teamID string) error

func (Store) DeleteProgramMetadata added in v1.1.4

func (db Store) DeleteProgramMetadata(program string) error

func (Store) DeleteTeam added in v1.1.4

func (db Store) DeleteTeam(teamID string) error

func (Store) DeleteTeamMember added in v1.1.4

func (db Store) DeleteTeamMember(teamID string, userID string) error

func (Store) DeleteUserByID added in v1.1.4

func (db Store) DeleteUserByID(userID string) error

func (Store) DisjoinAssetsInGroups added in v1.1.4

func (db Store) DisjoinAssetsInGroups(teamID, inGroupID string, notInGroupIDs []string) ([]*api.Asset, error)

func (Store) FindAsset added in v1.1.4

func (db Store) FindAsset(teamID, assetID string) (*api.Asset, error)

func (Store) FindChecktypeSetting added in v1.1.4

func (db Store) FindChecktypeSetting(checktypeSettingID string) (*api.ChecktypeSetting, error)

func (Store) FindGlobalProgramMetadata added in v1.1.4

func (db Store) FindGlobalProgramMetadata(programID string, teamID string) (*api.GlobalProgramsMetadata, error)

func (Store) FindGroup added in v1.1.4

func (db Store) FindGroup(group api.Group) (*api.Group, error)

func (Store) FindGroupInfo added in v1.1.4

func (db Store) FindGroupInfo(group api.Group) (*api.Group, error)

func (Store) FindJob added in v1.1.4

func (db Store) FindJob(jobID string) (*api.Job, error)

FindJob retrieves a Job by its ID

func (Store) FindPolicy added in v1.1.4

func (db Store) FindPolicy(policyID string) (*api.Policy, error)

func (Store) FindProgram added in v1.1.4

func (db Store) FindProgram(programID string, teamID string) (*api.Program, error)

func (Store) FindTeam added in v1.1.4

func (db Store) FindTeam(teamID string) (*api.Team, error)

FindTeam returns a team filtering by id

func (Store) FindTeamByIDForUser added in v1.1.4

func (db Store) FindTeamByIDForUser(ID, userID string) (*api.UserTeam, error)

FindTeamByIDForUser returns the membership information of a user in a team.

func (Store) FindTeamByName added in v1.1.4

func (db Store) FindTeamByName(name string) (*api.Team, error)

FindTeamByName returns a team filtering by name

func (Store) FindTeamByProgram added in v1.1.4

func (db Store) FindTeamByProgram(programID string) (*api.Team, error)

FindTeamByProgram returns the team that the given Program belongs to.

func (Store) FindTeamByTag added in v1.1.4

func (db Store) FindTeamByTag(tag string) (*api.Team, error)

FindTeamByTag returns a team filtering by tag

func (Store) FindTeamMember added in v1.1.4

func (db Store) FindTeamMember(teamID string, userID string) (*api.UserTeam, error)

func (Store) FindTeamsByTags added in v1.1.4

func (db Store) FindTeamsByTags(tags []string) ([]*api.Team, error)

FindTeamByTags returns all teams with any of the specified tags.

func (Store) FindTeamsByUser added in v1.1.4

func (db Store) FindTeamsByUser(userID string) ([]*api.Team, error)

func (Store) FindUserByEmail added in v1.1.4

func (db Store) FindUserByEmail(email string) (*api.User, error)

FindUserByEmail query a user by his email

func (Store) FindUserByID added in v1.1.4

func (db Store) FindUserByID(userID string) (*api.User, error)

FindUserByID query a user by his ID

func (Store) GetAssetType added in v1.1.4

func (db Store) GetAssetType(name string) (*api.AssetType, error)

func (Store) GroupAsset added in v1.1.4

func (db Store) GroupAsset(assetsGroup api.AssetGroup, teamID string) (*api.AssetGroup, error)

func (Store) Healthcheck added in v1.1.4

func (db Store) Healthcheck() error

Healthcheck simply checks for database connectivity

func (Store) IsDuplicateError added in v1.1.4

func (db Store) IsDuplicateError(err error) bool

DuplicateError is an utility method to check if a returned error is a duplicate key error.

func (Store) ListAssetAnnotations added in v1.1.4

func (db Store) ListAssetAnnotations(teamID string, assetID string) ([]*api.AssetAnnotation, error)

ListAssetAnnotations returns all annotations of a given asset id.

func (Store) ListAssetGroup added in v1.1.4

func (db Store) ListAssetGroup(assetGroup api.AssetGroup, teamID string) ([]*api.AssetGroup, error)

func (Store) ListAssets added in v1.1.4

func (db Store) ListAssets(teamID string, asset api.Asset) ([]*api.Asset, error)

func (Store) ListChecktypeSetting added in v1.1.4

func (db Store) ListChecktypeSetting(policyID string) ([]*api.ChecktypeSetting, error)

func (Store) ListFindingOverwrites added in v1.1.4

func (db Store) ListFindingOverwrites(findingID string) ([]*api.FindingOverwrite, error)

func (Store) ListGroups added in v1.1.4

func (db Store) ListGroups(teamID, groupName string) ([]*api.Group, error)

func (Store) ListPolicies added in v1.1.4

func (db Store) ListPolicies(teamID string) ([]*api.Policy, error)

func (Store) ListPrograms added in v1.1.4

func (db Store) ListPrograms(teamID string) ([]*api.Program, error)

func (Store) ListRecipients added in v1.1.4

func (db Store) ListRecipients(teamID string) ([]*api.Recipient, error)

ListRecipients ...

func (Store) ListTeams added in v1.1.4

func (db Store) ListTeams() ([]*api.Team, error)

ListTeams returns all teams

func (Store) ListUsers added in v1.1.4

func (db Store) ListUsers() ([]*api.User, error)

func (Store) MergeAssets added in v1.1.4

func (db Store) MergeAssets(mergeOps api.AssetMergeOperations) error

MergeAssets executes the operations required to update a discovery group in a single transaction.

func (Store) MergeAssetsAsync added in v1.1.4

func (db Store) MergeAssetsAsync(teamID string, assets []api.Asset, groupName string) (*api.Job, error)

MergeAssetsAsync stores the information required to execute a MergeAssets operation in the Outbox. It also creates a Job to be returned to the user to track the progress of the async operation.

func (Store) NewAssetReader added in v1.1.4

func (db Store) NewAssetReader(lock bool, pageSize int) (AssetsReader, error)

NewAssetReader creates a new AssetsReader with the given page size. If the lock param is set to true it will lock for writing the following tables: Assets, Teams and AssetAnnotations.

func (Store) NotFoundError added in v1.1.4

func (db Store) NotFoundError(err error) bool

NotFoundError is an utility method to check if a returned error is a not found error. This is needed because sometimes the services will need to act different depppending if an error is because a record it's not found or because other causes.

func (Store) PutAssetAnnotations added in v1.1.4

func (db Store) PutAssetAnnotations(teamID string, assetID string, annotations []*api.AssetAnnotation) ([]*api.AssetAnnotation, error)

PutAssetAnnotations overrides all annotations of a given asset with new content. Previous annotations will not ne preserved.

func (Store) UngroupAssets added in v1.1.4

func (db Store) UngroupAssets(assetGroup api.AssetGroup, teamID string) error

func (Store) UpdateAsset added in v1.1.4

func (db Store) UpdateAsset(asset api.Asset) (*api.Asset, error)

func (Store) UpdateAssetAnnotations added in v1.1.4

func (db Store) UpdateAssetAnnotations(teamID string, assetID string, annotations []*api.AssetAnnotation) ([]*api.AssetAnnotation, error)

UpdateAssetAnnotations updates the value of the existing annotations of a given asset.

func (Store) UpdateChecktypeSetting added in v1.1.4

func (db Store) UpdateChecktypeSetting(checktypeSetting api.ChecktypeSetting) (*api.ChecktypeSetting, error)

func (Store) UpdateGlobalProgramMetadata added in v1.1.4

func (db Store) UpdateGlobalProgramMetadata(metadata api.GlobalProgramsMetadata) error

func (Store) UpdateGroup added in v1.1.4

func (db Store) UpdateGroup(group api.Group) (*api.Group, error)

func (Store) UpdateJob added in v1.1.4

func (db Store) UpdateJob(job api.Job) (*api.Job, error)

func (Store) UpdatePolicy added in v1.1.4

func (db Store) UpdatePolicy(policy api.Policy) (*api.Policy, error)

func (Store) UpdateProgram added in v1.1.4

func (db Store) UpdateProgram(program api.Program, teamID string) (*api.Program, error)

func (Store) UpdateRecipients added in v1.1.4

func (db Store) UpdateRecipients(teamID string, emails []string) error

UpdateRecipients ...

func (Store) UpdateTeam added in v1.1.4

func (db Store) UpdateTeam(team api.Team) (*api.Team, error)

UpdateTeam updates a team in the database. It verifies if the team exists before actually making the update

func (Store) UpdateTeamMember added in v1.1.4

func (db Store) UpdateTeamMember(teamMember api.UserTeam) (*api.UserTeam, error)

func (Store) UpdateUser added in v1.1.4

func (db Store) UpdateUser(user api.User) (*api.User, error)

UpdateUser modifies an existing user in the database

func (Store) UpsertGlobalProgramMetadata added in v1.1.4

func (db Store) UpsertGlobalProgramMetadata(teamID, program string, defaultAutosend bool, defaultDisabled bool, defaultCron string, autosend *bool, disabled *bool, cron *string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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