app

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package app runs the pipeline: Validate, Discover, NewPlan, Execute, and Report.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Archive

func Archive(ctx context.Context, discovery Discovery, options Options, archivePath string) (int, error)

Archive returns how many files and directories it captured.

func DumpKeys

func DumpKeys(ctx context.Context, discovery Discovery, options Options) (masterkey.Dump, error)

DumpKeys keeps the keys that worked when a dir's others fail, and leaves out a dir with none. It fails only when the run is stopped, so a stopped run writes no keys.json.

func Report

func Report(writer io.Writer, summary Summary) error

Report prints a summary that is not part of the output contract and never changes the exit status.

Types

type Discovery

type Discovery struct {
	Dirs   []browser.UserDataDir
	Failed []Result
}

Discovery holds an error result per browser whose data could not be read, so it is reported, not taken as absence.

func Discover

func Discover(options Options) Discovery

Discover applies -p only when one browser is named.

func RestoreDiscovery

func RestoreDiscovery(
	root string, dump masterkey.Dump, options Options,
) (Discovery, map[browser.UserDataDirID]masterkey.Set, error)

RestoreDiscovery rebuilds the user data dirs under root, and their keys, from the dump: each vault names a subdirectory of root, or root is one browser's User Data.

type Extraction

type Extraction struct {
	UserDataDirID browser.UserDataDirID
	Profile       string            // Profile.Name; "" in a result about a whole user data dir
	Category      category.Category // zero in a result about a whole user data dir
}

Extraction is plain data, looked up again when it runs, so a Plan prints as it is and compares with DeepEqual.

type Flags

type Flags struct {
	Browser               string
	Categories            string
	Format                string
	Dir                   string
	Zip                   bool
	ProfilePath           string
	KeychainPassword      string
	KeychainPasswordStdin bool
}

type Options

type Options struct {
	Browser     string // "all" or one Browser.Name
	Categories  []category.Category
	Format      export.Format
	Dir         string
	Zip         bool
	ProfilePath string
	Home        string

	// KeychainPassword runs when the keychain first opens; "" leaves it locked, and nil, as list has it, silently.
	KeychainPassword func(ctx context.Context) (string, error)
	// Keys are a dump's keys by user data dir; nil retrieves every dir's keys from this machine.
	Keys map[browser.UserDataDirID]masterkey.Set
}

func ListOptions

func ListOptions() (Options, error)

ListOptions is what list reads: every browser and category, with the keychain left locked, so counting never prompts.

func Validate

func Validate(flags Flags) (Options, error)

Validate checks every flag before any browser or secret is touched, so a bad flag fails fast.

func ValidateArchive

func ValidateArchive(flags Flags) (Options, error)

ValidateArchive takes no keychain password: an archive copies files and reads no secret.

func ValidateKeys

func ValidateKeys(flags Flags) (Options, error)

func ValidateRestore

func ValidateRestore(flags RestoreFlags) (Options, masterkey.Dump, error)

ValidateRestore checks restore's flags and reads its keys before any data is opened. A restore's browsers are the dump's vaults, not this OS's table, so -b is checked against them.

type Outcome

type Outcome int

Outcome is how one extraction ended. It starts at 1, so a result whose outcome was never set does not read as ok.

const (
	OutcomeOK Outcome = iota + 1
	OutcomePartial
	OutcomeAbsent
	OutcomeUnsupported
	OutcomeError
)

func (Outcome) String

func (o Outcome) String() string

type Plan

type Plan struct {
	Dirs        []browser.UserDataDir
	Files       []snapshot.File
	Extractions []Extraction
	Skipped     []Result
}

Plan lists extractions in output order, each file to capture once, and the requested extractions that cannot run.

func NewPlan

func NewPlan(discovery Discovery, options Options) Plan

NewPlan only stats the files the extractors' file specs name, so it opens nothing and needs no keychain.

type RestoreFlags

type RestoreFlags struct {
	Keys       string // a keys.json path, or "-" for stdin
	DataDir    string
	DataZip    string
	Browser    string
	Categories string
	Format     string
	Dir        string
	Zip        bool
}

RestoreFlags are restore's command-line values as cobra parsed them.

type Result

type Result struct {
	Extraction
	Outcome Outcome
	Count   int   // records emitted
	Failed  int   // record-level problems reported
	Err     error // set when Outcome is OutcomeError
}

Result is one extraction's outcome, or a failure of a whole user data dir when Profile and Category are empty.

type Summary

type Summary struct {
	Results []Result
}

Summary is every result of a run, in output order: what never ran first, then each user data dir's extractions.

func Count

func Count(ctx context.Context, plan Plan, options Options) (Summary, error)

Count runs the plan with no key and the keychain locked, counting records instead of exporting them.

func Execute

func Execute(ctx context.Context, plan Plan, options Options) (Summary, error)

Execute handles one user data dir at a time, so at most one dir's copies are on disk. Its error means the run could not finish; every other failure is a Result.

Jump to

Keyboard shortcuts

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