kdbx

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package kdbx handles kdbx interactions

Package kdbx handles kdbx interactions

Package kdbx handles querying a store

Index

Constants

View Source
const (

	// OTPField is the totp storage attribute
	OTPField = "otp"
	// NotesField is the multiline notes key
	NotesField = "Notes"
	// URLField is a non-secret (in terms of input) entry field
	URLField = "URL"
)

Variables

View Source
var (

	// AllowedFields are the same of allowed names for storing in a kdbx entry
	AllowedFields = []string{NotesField, OTPField, "Password", URLField}
)

Functions

func Base

func Base(s string) string

Base will get the base name of input path

func Directory

func Directory(s string) string

Directory will get the directory/group for the given path

func Glob added in v1.7.0

func Glob(criteria, path string) (bool, error)

Glob is the baseline query for globbing for results

func IsDirectory

func IsDirectory(path string) bool

IsDirectory will indicate if a path looks like a group/directory

func IsLeafAttribute

func IsLeafAttribute(path, attr string) bool

IsLeafAttribute indicates if a path is leaved with a certain name

func NewPath

func NewPath(segments ...string) string

NewPath creates a new storage location path.

func NewSuffix

func NewSuffix(name string) string

NewSuffix creates a new user 'name' suffix

Types

type Context

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

Context handles operating on the underlying database

type Entity

type Entity struct {
	Values EntityValues
	Path   string
}

Entity are database objects from results and transactional changes

func (Entity) Value

func (e Entity) Value(key string) (string, bool)

Value will read an entity value

type EntityValues

type EntityValues map[string]string

EntityValues are what is stored, from an entity, into kdbx backing store

type QueryMode

type QueryMode int

QueryMode indicates HOW an entity will be found

const (

	// ListMode indicates ALL entities will be listed
	ListMode QueryMode
	// FindMode indicates a _contains_ search for an entity
	FindMode
	// ExactMode means an entity must MATCH the string exactly
	ExactMode
	// GlobMode indicates use a glob/match to find results
	GlobMode
)

type QueryOptions

type QueryOptions struct {
	Criteria string
	Mode     QueryMode
	Values   ValueMode
}

QueryOptions indicates how to find entities

type QuerySeq2

type QuerySeq2 iter.Seq2[Entity, error]

QuerySeq2 wraps the iteration for query entities

func (QuerySeq2) Collect

func (s QuerySeq2) Collect() ([]Entity, error)

Collect will create a slice from an iterable set of query sequence results

type Transaction

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

Transaction handles the overall operation of the transaction

func Load

func Load(file string) (*Transaction, error)

Load will load a kdbx file for transactions

func NewTransaction

func NewTransaction() (*Transaction, error)

NewTransaction will use the underlying environment data store location

func (*Transaction) Get

func (t *Transaction) Get(path string, mode ValueMode) (*Entity, error)

Get will request a singular entity

func (*Transaction) Insert

func (t *Transaction) Insert(path string, val EntityValues) error

Insert is a move to the same location

func (*Transaction) MatchPath

func (t *Transaction) MatchPath(path string) ([]Entity, error)

MatchPath will try to match 1 or more elements (more elements when globbing)

func (*Transaction) Move

func (t *Transaction) Move(src *Entity, dst string) error

Move will move a src object to a dst location

func (*Transaction) QueryCallback

func (t *Transaction) QueryCallback(args QueryOptions) (QuerySeq2, error)

QueryCallback will retrieve a query based on setting

func (*Transaction) ReKey

func (t *Transaction) ReKey(pass, keyFile string) error

ReKey will change the credentials on a database

func (*Transaction) Remove

func (t *Transaction) Remove(entity *Entity) error

Remove will remove a single entity

func (*Transaction) RemoveAll

func (t *Transaction) RemoveAll(entities []Entity) error

RemoveAll handles removing elements

type ValueMode

type ValueMode int

ValueMode indicates what to do with the store value of the entity

const (
	// BlankValue will not decrypt secrets, empty value
	BlankValue ValueMode = iota
	// SecretValue will have the raw secret onboard
	SecretValue
	// JSONValue will show entries as a JSON payload
	JSONValue
)

Jump to

Keyboard shortcuts

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