Documentation
¶
Overview ¶
Package dataset builds the export dataset: every profile, key, host and token of a home as typed, related records, with no secret on any of them.
It is the first stage of the export pipeline (dataset, then a selection, then a format). It reads through the same services the pages and the CLI use, so a fact has one source: a host's status is query's, a key's state is keysvc's, a token's presence is tokensvc's. Records link by name (a host's Key is a key's Ref), never by copying, so a selection can follow a relation in either direction.
Index ¶
Constants ¶
const ( // PartCore asks for none of the optional parts: profiles, keys and hosts only. PartCore = "core" PartTokens = "tokens" PartOps = "ops" PartEvents = "events" PartSnapshots = "snapshots" PartDeployments = "deployments" )
The optional parts.
const Version = 1
Version is the dataset's shape. A field is only ever added; a rename or a removal bumps it, so a saved selection can tell what it was written for.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dataset ¶
type Dataset struct {
Version int `json:"version"`
Profiles []Profile `json:"profiles"`
Keys []Key `json:"keys"`
Hosts []Host `json:"hosts"`
Tokens []Token `json:"tokens"`
// The parts below are read only when asked for (Options.Parts): history
// opens a database, and a snapshot is read to tell whether it holds keys.
Ops []Op `json:"ops"`
Events []Event `json:"events"`
Snapshots []Snapshot `json:"snapshots"`
Deployments []Deployment `json:"deployments"`
}
Dataset is a home's records, in manifest order within each list.
type Deployment ¶
type Deployment struct {
KeyPath string `json:"key_path"`
Fingerprint string `json:"fingerprint"`
Status string `json:"status"` // not-deployed, needs-redeploy or deployed
Target string `json:"target"`
Method string `json:"method"`
Verified bool `json:"verified"`
Date string `json:"date"`
}
Deployment is one place a recorded key is deployed, or a key deployed nowhere (Target empty), as `ssh audit --csv` lists them.
type Event ¶
type Event struct {
Time string `json:"time"` // RFC 3339, UTC
Seen string `json:"seen"`
Kind string `json:"kind"` // added, changed, removed, mode, started
Area string `json:"area"` // ssh, config, auth
Path string `json:"path"`
Size int64 `json:"size"`
Mode string `json:"mode"`
Detail string `json:"detail"`
}
Event is one change the events log saw in a watched file.
type Host ¶
type Host struct {
Alias string `json:"alias"`
Profile string `json:"profile"`
Hostname string `json:"hostname"`
User string `json:"user"`
Port int `json:"port"`
Provider string `json:"provider"` // e.g. github/vcs or server
Key string `json:"key"` // the key's name; "" when it has none
KeyRef string `json:"key_ref"` // profile/name, to join with Key.Ref
Status string `json:"status"`
Tags []string `json:"tags"`
Env string `json:"env"` // parsed from the alias by the naming rules; "" for an older name
Role string `json:"role"` // likewise
Code string `json:"code"` // likewise
Number string `json:"number"` // likewise, as written (00)
Named bool `json:"named"` // the alias follows the naming rules
RequiresVPN bool `json:"requires_vpn"`
VPNName string `json:"vpn_name"`
VM bool `json:"vm"`
Proxy bool `json:"proxy"`
TokenEnv string `json:"token_env"` // the variable's name, never its value
Options []Option `json:"options"` // raw ssh_config options, in order
}
Host is one host with every SSH setting it has.
type Key ¶
type Key struct {
Ref string `json:"ref"` // profile/name, the selector the CLI takes
Profile string `json:"profile"`
Name string `json:"name"`
Type string `json:"type"`
Fingerprint string `json:"fingerprint"`
Created string `json:"created"`
ExpiresOn string `json:"expires_on"`
RotateAfterDays int `json:"rotate_after_days"`
Store string `json:"store"` // disk or 1password
OnDisk bool `json:"on_disk"`
Recorded bool `json:"recorded"` // the inventory records it
State string `json:"state"` // no-key, not-deployed, needs-redeploy, deployed
Hosts []string `json:"hosts"` // aliases using it
Deployments int `json:"deployments"`
}
Key is one key: where it is, what it is, and which hosts use it.
type Naming ¶
type Naming struct {
Alias string `json:"alias"`
KeyName string `json:"key_name"`
Envs []string `json:"envs"`
Roles []string `json:"roles"`
Enforce string `json:"enforce"`
}
Naming is the naming rules in effect for a profile.
type Op ¶
type Op struct {
OpID string `json:"op_id"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
Command string `json:"command"`
Args []string `json:"args"`
Result string `json:"result"`
Source string `json:"source"` // cli, web, tui, ...
User string `json:"user"`
Machine string `json:"machine"`
Snapshot string `json:"snapshot"`
Subjects []string `json:"subjects"` // kind:name each
Events []string `json:"events"` // the audit events it raised
}
Op is one recorded operation: what ran, who ran it, and what it touched.
type Options ¶
type Options struct {
// Getenv finds the token files (HOME and the tools' own variables);
// nil is os.Getenv, as the tokens page does.
Getenv func(string) string
// Cwd is the directory project-level token files are looked for in; ""
// is the working directory.
Cwd string
// Parts are the optional parts to read: PartTokens, PartOps, PartEvents,
// PartSnapshots, PartDeployments. Empty reads every one; PartCore alone
// reads none. Profiles, keys and hosts are always read.
Parts []string
// History and Events narrow those parts as their pages' filters do, so a
// download of a filtered page holds what the page shows.
History history.Filter
Events events.Filter
}
Options are what Build reads from the process, for a test to replace.
type Profile ¶
type Profile struct {
Name string `json:"name"`
Code string `json:"code"` // its own code, or the fallback in effect; "" when none
OwnCode bool `json:"own_code"` // Code is the profile's own, not the fallback
Category string `json:"category"` // orgs, clients, personal, ...
KeyScope string `json:"key_scope"` // per_service, per_host, ...
KeyStore string `json:"key_store"` // disk or 1password
KeyComment string `json:"key_comment"` // its own key_comment template; "" inherits
Naming Naming `json:"naming"` // the naming rules in effect for it
Hosts int `json:"hosts"`
Keys int `json:"keys"`
}
Profile is one profile and its rules.
type Snapshot ¶
type Snapshot struct {
Name string `json:"name"`
Taken string `json:"taken"` // RFC 3339, UTC
Bytes int64 `json:"bytes"`
HoldsPrivateKeys bool `json:"holds_private_keys"` // from before key exclusion
}
Snapshot is one snapshot file.
type Token ¶
type Token struct {
Target string `json:"target"` // the tool: npm, composer, git, ...
Host string `json:"host"`
Kind string `json:"kind"`
Username string `json:"username"`
SecretPresent bool `json:"secret_present"`
Description string `json:"description"`
File string `json:"file"`
}
Token is one installed credential, described: never the secret.