bdb

package
v0.0.0-...-0388672 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentStorageVersion = 1.0

CurrentStorageVersion describes what storage version we're on and can be used to determine if the underlying database structure needs to change

Variables

This section is empty.

Functions

func DeviceMatch

func DeviceMatch(v storage.CLDevices) q.Matcher

DeviceMatch returns true if *any* element inside v is inside "AssignedToDevices" in a task document

func Init

func Init(cfg storage.Config) (storage.Backend, error)

Init creates a database instance backed by boltdb

func StringContains

func StringContains(field, contains string) q.Matcher

StringContains checks if the given field value contains any of the text in contains

Types

type BoltBackend

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

BoltBackend is a storage backend for GoCrack built ontop of Bolt/LMDB

func (*BoltBackend) ChangeTaskStatus

func (s *BoltBackend) ChangeTaskStatus(taskID string, status storage.TaskStatus, potentialError *string) error

func (*BoltBackend) CheckEntitlement

func (s *BoltBackend) CheckEntitlement(userUUID, entityID string, entType storage.EntitlementType) (bool, error)

CheckEntitlement implements storage.CheckEntitlement

func (*BoltBackend) Close

func (s *BoltBackend) Close() error

Close the resources used by bolt

func (*BoltBackend) CreateUser

func (s *BoltBackend) CreateUser(user *storage.User) (err error)

CreateUser saves the record into the database

func (*BoltBackend) DeleteEngineFile

func (s *BoltBackend) DeleteEngineFile(fileID string) error

DeleteEngineFile file implements storage.DeleteEngineFile

func (*BoltBackend) DeleteTask

func (s *BoltBackend) DeleteTask(taskid string) error

DeleteTask implements storage.DeleteTask

func (*BoltBackend) DeleteTaskFile

func (s *BoltBackend) DeleteTaskFile(fileID string) error

DeleteTaskFile implements storage.DeleteTaskFile

func (*BoltBackend) EditUser

func (s *BoltBackend) EditUser(userUUID string, req storage.UserModifyRequest) error

func (*BoltBackend) GetActivityLog

func (s *BoltBackend) GetActivityLog(entityID string) ([]storage.ActivityLogEntry, error)

GetActivityLog implements storage.GetActivityLog

func (*BoltBackend) GetCrackedPasswords

func (s *BoltBackend) GetCrackedPasswords(taskid string) (*[]storage.CrackedHash, error)

func (*BoltBackend) GetEngineFileByID

func (s *BoltBackend) GetEngineFileByID(storageID string) (*storage.EngineFile, error)

GetEngineFileByID returns the engine file given it's unique ID

func (*BoltBackend) GetEngineFilesForUser

func (s *BoltBackend) GetEngineFilesForUser(user storage.User) (sfs []storage.EngineFile, err error)

GetEngineFilesForUser returns a list of engine files available to the user

func (*BoltBackend) GetEntitlementsForTask

func (s *BoltBackend) GetEntitlementsForTask(entityID string) ([]storage.EntitlementEntry, error)

GetEntitlementsForTask implements storage.GetEntitlementsForTask

func (*BoltBackend) GetPendingTasks

func (*BoltBackend) GetTaskByID

func (s *BoltBackend) GetTaskByID(taskID string) (task *storage.Task, err error)

GetTaskByID returns a task record based on it's ID

func (*BoltBackend) GetTaskCheckpoint

func (s *BoltBackend) GetTaskCheckpoint(taskid string) ([]byte, error)

GetTaskCheckpoint implements storage.GetTaskCheckpoint

func (*BoltBackend) GetTaskFileByID

func (s *BoltBackend) GetTaskFileByID(storageID string) (*storage.TaskFile, error)

GetTaskFileByID implements the storage.GetTaskFileByID API

func (*BoltBackend) GetUserByID

func (s *BoltBackend) GetUserByID(userUUID string) (*storage.User, error)

GetUserByID returns a user record given the users unique uuid.

func (*BoltBackend) GetUsers

func (s *BoltBackend) GetUsers() ([]storage.User, error)

GetUsers returns a list of all users within the GoCrack system

func (*BoltBackend) GrantEntitlement

func (s *BoltBackend) GrantEntitlement(user storage.User, entitledTo interface{}) (err error)

GrantEntitlement implements storage.GrantEntitlement

func (*BoltBackend) ListTasksForUser

func (s *BoltBackend) ListTasksForUser(user storage.User) ([]storage.TaskFile, error)

ListTasksForUser implements the storage.ListTasksForUser API

func (*BoltBackend) LogActivity

func (s *BoltBackend) LogActivity(entry storage.ActivityLogEntry) error

LogActivity implements storage.LogActivity

func (*BoltBackend) NewEngineFileTransaction

func (s *BoltBackend) NewEngineFileTransaction() (storage.EngineFileTxn, error)

func (*BoltBackend) NewTaskCreateTransaction

func (s *BoltBackend) NewTaskCreateTransaction() (storage.CreateTaskTxn, error)

NewTaskCreateTransaction creates a new transaction used by the task creation PUT API

func (*BoltBackend) NewTaskFileTransaction

func (s *BoltBackend) NewTaskFileTransaction() (storage.TaskFileTxn, error)

NewTaskFileTransaction creates a new transaction used by the task file PUT APIs

func (*BoltBackend) RemoveActivityEntries

func (s *BoltBackend) RemoveActivityEntries(entityID string) error

RemoveActivityEntries implements storage.RemoveActivityEntries

func (*BoltBackend) RemoveEntitlements

func (s *BoltBackend) RemoveEntitlements(entityID string, entType storage.EntitlementType) error

RemoveEntitlements implements storage.RemoveEntitlements

func (*BoltBackend) RevokeEntitlement

func (s *BoltBackend) RevokeEntitlement(user storage.User, document interface{}) error

RevokeEntitlement removes the users access to the document

func (*BoltBackend) SaveCrackedHash

func (s *BoltBackend) SaveCrackedHash(taskid, hash, value string, crackedAt time.Time) error

func (*BoltBackend) SaveTaskCheckpoint

func (s *BoltBackend) SaveTaskCheckpoint(checkpoint storage.CheckpointFile) error

SaveTaskCheckpoint implements storage.SaveTaskCheckpoint

func (*BoltBackend) SearchForUserByPassword

func (s *BoltBackend) SearchForUserByPassword(username string, checker storage.PasswordCheckFunc) (*storage.User, error)

SearchForUserByPassword locates the user record by username. If a record is found, the checker function will be called to validate the password.

func (*BoltBackend) TasksSearch

func (s *BoltBackend) TasksSearch(page, limit int, orderby, searchQuery string, isAscending bool, user storage.User) (*storage.SearchResults, error)

func (*BoltBackend) UpdateTask

func (s *BoltBackend) UpdateTask(taskid string, modifiedFields storage.ModifiableTaskRequest) error

type Driver

type Driver struct{}

func (*Driver) Open

func (s *Driver) Open(cfg storage.Config) (storage.Backend, error)

type EngineFileTransaction

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

func (*EngineFileTransaction) AddEntitlement

func (s *EngineFileTransaction) AddEntitlement(sf storage.EngineFile, userid string) error

func (*EngineFileTransaction) Commit

func (s *EngineFileTransaction) Commit() error

Commit the transaction

func (*EngineFileTransaction) Rollback

func (s *EngineFileTransaction) Rollback() error

Rollback any writes to the database

func (*EngineFileTransaction) SaveEngineFile

func (s *EngineFileTransaction) SaveEngineFile(sf storage.EngineFile) error

type StatsExporter

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

StatsExporter is used to export BoltDB stats to Prometheus

func NewExporter

func NewExporter(db *storm.DB) *StatsExporter

NewExporter creates a new StatsExporter for prometheus to allow us to peek at how BoltDB is performing

func (*StatsExporter) Collect

func (s *StatsExporter) Collect(ch chan<- prometheus.Metric)

Collect retrieves the current BoltDB statistics

func (*StatsExporter) Describe

func (s *StatsExporter) Describe(ch chan<- *prometheus.Desc)

Describe describes all the metrics exported by BoltDB

type TaskCreateTransaction

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

func (*TaskCreateTransaction) Commit

func (s *TaskCreateTransaction) Commit() error

Commit the transaction

func (*TaskCreateTransaction) CreateTask

func (s *TaskCreateTransaction) CreateTask(t *storage.Task) error

CreateTask creates the task within the context of a database transaction

func (*TaskCreateTransaction) GrantEntitlement

func (s *TaskCreateTransaction) GrantEntitlement(userUUID string, t storage.Task) error

GrantEntitlement grants additional users to the task within the context of a database transaction

func (*TaskCreateTransaction) Rollback

func (s *TaskCreateTransaction) Rollback() error

Rollback any writes to the database

type TaskFileTransaction

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

TaskFileTransaction is used in the creation of a task file and all the APIs it defines are executed under a bolt transaction

func (*TaskFileTransaction) AddEntitlement

func (s *TaskFileTransaction) AddEntitlement(tf storage.TaskFile, userid string) error

AddEntitlement creates a record giving the user access to the task file

func (*TaskFileTransaction) Commit

func (s *TaskFileTransaction) Commit() error

Commit the transaction

func (*TaskFileTransaction) Rollback

func (s *TaskFileTransaction) Rollback() error

Rollback any writes to the database

func (*TaskFileTransaction) SaveTaskFile

func (s *TaskFileTransaction) SaveTaskFile(tf storage.TaskFile) error

SaveTaskFile saves metadata regarding a task file to the database

Jump to

Keyboard shortcuts

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