cmd

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

The Add command is for adding secrets into the DB, the encryption part is handled inside the storage package.

autocomplete.go is where the functions related with the autocompletion on the cli reside.

Delete command, it deletes a secret, the secret to be deleted must be passed with the command itself, it's case sensitive, so GITHUB it's different from github. Ex.: agopass delete Github

Get command is used to get the actual secret from the DB, it will search the secret that you want based on the name passed on the command it is case sensitive, GITHUB is different from github, if it finds will copy the key to your clipboard. Ex.: agopass get Github

This is the first stop on the cmd package, is also the first command that should be run when using agopass, with it you define you Master Key, the only password that you need to remember, this password is prompted whenever you want to use a command that MODIFIES the content of DB, that means, List command will not need the auth via master key because it doesn't change anything on the DB, it doesn't show the password either, just the name with a mock hidden passwords, to get your password you use the command Get, this is one that needs auth, the following commands need Auth : add, get, delete. Auth will be called before this functions, after you use Init atleas one time, you can forget it exists, you will not be able to change your password, because the encryption of you other keys is done using the Master Key hash as salt, so if you forget you better of just removing the DB out of existence, than you can start over again.

List command shows all secrets that are registered on the DB, the keys that it shows are just a mock based on the length of the plain text key, therefore the user does not need to authenticate before using it.

The Make command creates a random 32 bit long key, if you compile it from source you can change the length, will add this eventually, the command uses the crypto/rand package to generate random numbers, crypto is used because it generates ranmdom numbers using a lot of entropy, making the 'randomnes' true, is not biased as well.

Update command is to update a already registered Secret on the DB, the user can change the name, the key, but not it's ID.

Utils, this file has function that: are used on more than one file and/or i didn't know where to put.

Index

Constants

View Source
const (
	BASH_COMP_SCRIPT = `` /* 320-byte string literal not displayed */

	ZSH_COMP_SCRIPT = `` /* 444-byte string literal not displayed */

)

The actuall shell scripts, it works with bash and zsh for now.

View Source
const (
	CHARS          = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*(),.<>;:/?{}[]"
	DEFAULT_LENGTH = 32
)

consts, CHARS is the string used to generate the random key, DEFAULT_LENGTH is the len of the generated key.

View Source
const (
	MAX_PASSWORD_RETRIES = 3
)
View Source
const (
	VERSION = "v0.0.2"
)

Variables

This section is empty.

Functions

func Add

func Add(db storage.DB, args []string)

Add function, it receives a DB connection.

func Authenticate

func Authenticate(db storage.DB) []byte

Authenticate function, receives a DB and returns a slice of bytes that is the hashed Master Key, it checks if the key exist, if it exists will prompt the user for it's Master Key, the user has 3 tries to get it right, if it fails the program will abort. If they get it right the program follows the normal flow.

func AutocompleteExists added in v1.0.0

func AutocompleteExists() (bool, error)

AutocompleteExists() check to see if the autocomplete script already exist on the .rc file.

func CheckAmountArguments

func CheckAmountArguments(args []string)

Check the amount of arguments passed on a args string slice, usually on the commands that need arguments only 3 total are needed, the binary, the command itself and an argument, more than this it's reject, less then 3 is also reject for this function is only called on commands that accept arguments.

func CheckArgumentSpelling added in v1.0.0

func CheckArgumentSpelling(args []string, db storage.DB) (storage.Secret, error)

CheckArgumentSpelling checks the spelling of the optional third argument, it checks if argument, when not a exact match, 'looks' like other Secrets on the DB, if it is it returns the instatieted Secret.

func Delete

func Delete(db storage.DB, args []string)

Delete function, receives a db connection and the arguments.

func Get

func Get(db storage.DB, args []string)

Get function receives a DB connection and a arguments slice.

func Init

func Init(db storage.DB)

Init function, is the one that register your Master Key, it needs a DB connection that is passed through it's argumments.

func InitAutocomplete added in v1.0.0

func InitAutocomplete() error

Main autocomplete function, this function setup the config on the .rc file of the user shell Ex.: .bashrc, .zshrc, it's expecting that the this file is in your home, it will not create the file if it doesn't exist, this could disrupt the config of the user, the user can just pass this script to other file, it just need to be sourced.

func IsMasterKeyHash

func IsMasterKeyHash(db storage.DB, s string) (bool, error)

IsMasterKeyHash function compares a string (that will be hashed by the function) with the hashed Master Key on DB, returning true if it is the Master Key, and false if not.

func List

func List(db storage.DB)

List function, accepts a DB connection.

func Make added in v1.0.0

func Make()

Make function receives nothing and return nothing, it generate the random key and paste it on your clipboard.

func PrintUsage

func PrintUsage(args []string)

Prints the agopass usage.

func Update added in v1.0.0

func Update(db storage.DB, args []string)

Update function receives a DB connection and the arguments string array, it returns nothing.

func Version added in v1.0.0

func Version()

Version prints the version of the program, wow.

Types

This section is empty.

Jump to

Keyboard shortcuts

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