Documentation
¶
Overview ¶
Package sshgate is the SSH channel: agents reach the machines Beacon knows with the tools they already use (ssh, scp, sftp, rsync, port forwarding) or with the MCP and REST tools, and never hold a key. Beacon signs a certificate valid for a few minutes for every connection to a machine, which trusts only Beacon's certificate authority, and records every session: asciicast v3 for replay, and a transcript that breaks an interactive shell into commands with their exit status.
It does not judge what runs. Reviewing commands is the agents' business, done by their own harness; people see every session, echoed to the alert chat, and can pause the channel.
Index ¶
- Constants
- Variables
- func ErrorCode(err error) string
- func RanBy(actor, who string) bool
- func TrustAccounts(users []string, redirect string) string
- type AccessRuleView
- type Actor
- type Added
- type Command
- type CommandCheck
- type ConnectorSetup
- type Deps
- type DirFiles
- func (d DirFiles) Create(name string) (io.WriteCloser, error)
- func (d DirFiles) CreateStaged(name string) (filecapture.Capture, error)
- func (d DirFiles) Open(name string) (io.ReadCloser, error)
- func (d DirFiles) ReadFile(name string) ([]byte, error)
- func (d DirFiles) Remove(name string) error
- func (d DirFiles) WriteFile(name string, b []byte) error
- type EditInput
- type FileEntry
- type FileOp
- type FileView
- type Files
- type Gate
- func (g *Gate) Access(who Actor, key string) (SubjectAccess, error)
- func (g *Gate) AccessRule(id string) (AccessRuleView, error)
- func (g *Gate) AccessRules() []AccessRuleView
- func (g *Gate) Add(ctx context.Context, who Actor, in MachineInput) (Added, error)
- func (g *Gate) CAPublicKey() string
- func (g *Gate) ChangeFiles(ctx context.Context, who Actor, machine string, op FileOp) error
- func (g *Gate) CheckCommand(key, machine, command string) (CommandCheck, error)
- func (g *Gate) CheckSSH(ctx context.Context, who Actor, machine, registration string) (SSHCheck, error)
- func (g *Gate) CommandRecords(p store.Principal, f store.RecordFilter) ([]store.CommandRecord, int, error)
- func (g *Gate) CommandRule(id string) (store.CommandRule, error)
- func (g *Gate) CommandRules() []store.CommandRule
- func (g *Gate) ConnectionConfig(who Actor, address, machine string) (config, knownHosts string)
- func (g *Gate) DeleteAccessRule(ctx context.Context, who Actor, id string) error
- func (g *Gate) DeleteCommandRule(ctx context.Context, who Actor, id string) error
- func (g *Gate) DeleteMachineGroup(ctx context.Context, who Actor, id string) error
- func (g *Gate) DeleteSchedule(ctx context.Context, who Actor, id string) error
- func (g *Gate) Detail(who Actor, name, address string) (MachineDetail, error)
- func (g *Gate) DownloadFile(ctx context.Context, who Actor, machine, account, file string, ...) error
- func (g *Gate) EditFile(ctx context.Context, who Actor, machine string, in EditInput) (Written, error)
- func (g *Gate) HostKey() string
- func (g *Gate) ImportMachines(ctx context.Context, who Actor, file []byte, commit bool) (ImportResult, error)
- func (g *Gate) ImportRows(ctx context.Context, who Actor, rows []ImportRow, commit bool) (ImportResult, error)
- func (g *Gate) InteractiveShell(ctx context.Context, who Actor, machineName string, ioStreams ShellIO) (Transcript, error)
- func (g *Gate) InterruptJobs()
- func (g *Gate) Job(p store.Principal, id string) (store.Job, error)
- func (g *Gate) Jobs(p store.Principal, f JobFilter) ([]store.Job, error)
- func (g *Gate) List(who Actor, address string) (Machines, error)
- func (g *Gate) ListFiles(ctx context.Context, who Actor, machine, account, dir string) (Listing, error)
- func (g *Gate) Live(id string) bool
- func (g *Gate) MachineGroups() []MachineGroupView
- func (g *Gate) MachineHistory(name string, before int64, limit int) (store.MachineHistory, error)
- func (g *Gate) Paused() bool
- func (g *Gate) PausedSince() time.Time
- func (g *Gate) PublicAddress() string
- func (g *Gate) Reachers(name string) ([]Reacher, error)
- func (g *Gate) ReadFile(ctx context.Context, who Actor, machine, path string, offset, limit int) (FileView, error)
- func (g *Gate) Recheck() int
- func (g *Gate) Recording(id string) (io.ReadCloser, error)
- func (g *Gate) RecordingFor(p store.Principal, id string) (io.ReadCloser, error)
- func (g *Gate) Remove(ctx context.Context, who Actor, name string) error
- func (g *Gate) RestoreMachine(ctx context.Context, who Actor, name string, in MachineRestore) (MachineView, error)
- func (g *Gate) Run(ctx context.Context, who Actor, machine string, in RunInput) (RunResult, error)
- func (g *Gate) RunPending(ctx context.Context)
- func (g *Gate) RunScheduleNow(ctx context.Context, who Actor, id string) (store.Job, error)
- func (g *Gate) RunSchedules(ctx context.Context) int
- func (g *Gate) SaveAccessRule(ctx context.Context, who Actor, r store.AccessRule, ifVersion int64) (AccessRuleView, error)
- func (g *Gate) SaveCommandRule(ctx context.Context, who Actor, r store.CommandRule, ifVersion int64) (store.CommandRule, error)
- func (g *Gate) SaveMachineGroup(ctx context.Context, who Actor, gr store.MachineGroup) (MachineGroupView, error)
- func (g *Gate) SaveSchedule(ctx context.Context, who Actor, s store.JobSchedule, ifVersion int64) (ScheduleView, error)
- func (g *Gate) Schedule(who Actor, id string) (ScheduleView, error)
- func (g *Gate) Schedules(who Actor) ([]ScheduleView, error)
- func (g *Gate) SearchFiles(ctx context.Context, who Actor, machine string, in SearchInput) (SearchResult, error)
- func (g *Gate) SendFile(ctx context.Context, who Actor, in SendFileInput, content []byte) (store.Job, error)
- func (g *Gate) Serve(ctx context.Context, ln net.Listener) error
- func (g *Gate) Session(id string) (Transcript, error)
- func (g *Gate) SessionCommands(ctx context.Context, p store.Principal, id string) ([]Command, error)
- func (g *Gate) SessionDetail(ctx context.Context, id string) (Transcript, error)
- func (g *Gate) SessionDetailFor(ctx context.Context, p store.Principal, id string) (Transcript, error)
- func (g *Gate) SessionFor(p store.Principal, id string) (Transcript, error)
- func (g *Gate) SessionTransfers(p store.Principal, id string) ([]store.TransferRecord, error)
- func (g *Gate) Sessions(f SessionFilter) ([]SessionView, error)
- func (g *Gate) SessionsFor(p store.Principal, f SessionFilter) ([]SessionView, error)
- func (g *Gate) SetConnector(ctx context.Context, who Actor, name, key string) (MachineView, error)
- func (g *Gate) SetGroupMachines(ctx context.Context, who Actor, id string, add, remove []string) (MachineGroupView, error)
- func (g *Gate) SetLeader(fn func() bool)
- func (g *Gate) SetPaused(ctx context.Context, who Actor, paused bool) error
- func (g *Gate) SetWatermark(mode string)
- func (g *Gate) StartJob(ctx context.Context, who Actor, in JobInput) (store.Job, error)
- func (g *Gate) StopJob(ctx context.Context, who Actor, id string) (store.Job, error)
- func (g *Gate) Store() *store.Store
- func (g *Gate) Terminate(ctx context.Context, who Actor, id, reason string) error
- func (g *Gate) Tidy(ctx context.Context)
- func (g *Gate) TidyMachineAccess() int
- func (g *Gate) TransferRecords(p store.Principal, f store.RecordFilter) ([]store.TransferRecord, int, error)
- func (g *Gate) Update(ctx context.Context, who Actor, name string, in MachineUpdate) (MachineView, error)
- func (g *Gate) UpdateSettings(publicAddr string, sourceAddrs []string, keep time.Duration, lang i18n.Lang, ...)
- func (g *Gate) UploadFile(ctx context.Context, who Actor, machine, account, file string, r io.Reader) (int64, error)
- func (g *Gate) WaitJob(ctx context.Context, p store.Principal, id string, d time.Duration) (store.Job, error)
- func (g *Gate) Watch(ctx context.Context, p store.Principal, id string) (LiveHeader, <-chan LiveEvent, error)
- func (g *Gate) WriteFile(ctx context.Context, who Actor, machine, path, content string) (Written, error)
- type ImportResult
- type ImportRow
- type JobFilter
- type JobInput
- type Listing
- type LiveEvent
- type LiveHeader
- type MachineDetail
- type MachineGroupView
- type MachineInput
- type MachineRestore
- type MachineUpdate
- type MachineView
- type Machines
- type Poster
- type Reach
- type Reacher
- type RunInput
- type RunResult
- type SSHCheck
- type SSHCheckStatus
- type ScheduleView
- type SearchInput
- type SearchMatch
- type SearchResult
- type SendFileInput
- type SessionFilter
- type SessionView
- type ShellEvent
- type ShellIO
- type ShellStart
- type SubjectAccess
- type Transcript
- type Written
Constants ¶
const ( MaxImportRows = 500 MaxImportBytes = 1 << 20 )
MaxImportRows and maxImportBytes bound one file.
const ( ImportReady = "ready" ImportProblem = "problem" ImportAdded = "added" ImportFailed = "failed" )
Import row states.
const AddMachineDocs = "https://beacon.openlinkos.com/guide/machines#add-a-machine"
AddMachineDocs is the guide's section on making a machine's accounts trust Beacon's certificates, which ErrAuthRefused points to.
const MaxJobMachines = 100
MaxJobMachines is how many machines one job runs on at most.
const MaxSendFile = 64 << 20
MaxSendFile is the largest file sent to many machines at once (Beacon holds it while it sends).
const PauseKey = "ssh_paused"
PauseKey is where the start of a pause is stored; zero when the channel runs.
const PersonalConfigPath = "~/.ssh/beacon-personal.conf"
PersonalConfigPath is the dedicated OpenSSH configuration file for the console's personal connection.
Variables ¶
var ( ErrRuleChanged = errors.New("the rule changed since it was read; reload it and try again") ErrDirectRule = errors.New("this rule is a subject's own machine access") )
Errors of rules.
var ( ErrDisabled = errors.New("the SSH channel is not configured") ErrPaused = errors.New("access to machines is paused") ErrStandby = errors.New("this instance is the standby; tools run on the primary") ErrNoMachine = errors.New("no such machine") ErrForbidden = errors.New("you may not reach the machine") ErrUnreachable = errors.New("the machine cannot be reached") // ErrAuthRefused is a machine that answered, with its pinned host key, but refused Beacon's // certificate for the account: the account does not exist there, or its sshd does not trust // Beacon's certificate authority for it. ErrAuthRefused = errors.New("the machine refused the account's certificate") ErrExists = errors.New("a machine with this name exists") ErrBadInput = errors.New("bad input") ErrNoFile = errors.New("no such file") ErrNotRegular = errors.New("not a regular file") ErrBinary = errors.New("the file is binary") ErrTooLarge = errors.New("the file is too large") ErrChanged = errors.New("the file changed since it was read") ErrNoMatch = errors.New("old_string is not in the file") ErrAmbiguous = errors.New("old_string occurs more than once") ErrNoSession = errors.New("no such session") // ErrDenied is work the access rules do not allow: an account or an action on a machine the // principal reaches. ErrDenied = errors.New("access rules do not allow this") // ErrBlocked is a command a command rule refuses. ErrBlocked = errors.New("a command rule refuses this command") ErrRecordingLimit = errors.New("the session reached its recording limit and Beacon closed it") ErrRecordingFailed = errors.New("the session's recording could not be written, and Beacon closed it") )
Errors the API and MCP turn into answers. They are wrapped with details.
var ( ErrMachineChanged = errors.New("machine settings changed; reload the current version and try again") ErrMachineVersion = errors.New("no such version in this machine's current registration") )
var ErrAlias = errors.New("another machine has this address or host key")
ErrAlias is the answer for a machine that would be another machine's second record.
var ErrDisconnected = errors.New("the machine's connector is not connected; it connects out to the channel with ssh -R")
ErrDisconnected is the answer for a connector machine whose connection is not up.
var ErrImportFile = errors.New("the file is not a CSV of machines")
ErrImportFile is a file that is not one Beacon can read as machines.
var ErrNoGroup = errors.New("no such machine group")
ErrNoGroup is a machine group that does not exist.
var ErrNoJob = errors.New("no such job")
ErrNoJob is a job that does not exist, or that the caller may not see.
var ErrNoRule = errors.New("no such rule")
ErrNoRule is a rule that does not exist.
var ErrNoSchedule = errors.New("no such schedule")
ErrNoSchedule is a schedule that does not exist, or that the caller may not see.
var ErrNoSubject = errors.New("no such subject")
ErrNoSubject is a subject that does not resolve.
var ErrNotLive = errors.New("the session is not open")
ErrNotLive is a session that is not open (any more).
ErrRecordingUnavailable identifies a visible session that cannot currently be replayed.
var ErrResumeByPerson = errors.New("only a person, or beacon ssh resume on the host, resumes SSH access")
ErrResumeByPerson is the answer to an agent or a token that asks to resume the channel.
ErrSSHCheckUnavailable means Beacon could not prepare the certificate or persist its audit.
ErrSearchUnavailable means the enrolled machine lacks the standard shell utilities for search.
var ErrTerminateForbidden = errors.New("ending a session takes a person with machines:write who may see it, or the session's own principal")
ErrTerminateForbidden is the answer to whoever may not end a session.
var ErrTerminated = errors.New("the session was ended by a person")
ErrTerminated is the answer to a tool call whose session someone ended.
Functions ¶
func ErrorCode ¶
ErrorCode is the stable code of an error of the channel, as the API answers it: for a job's machine that was refused.
func RanBy ¶
RanBy reports whether a session's actor (as the audit log names it) is who: the whole name, or the person or the agent of "person / agent".
func TrustAccounts ¶
TrustAccounts is the shell line that has the machine's sshd trust Beacon's certificate authority for the accounts Beacon signs in as, and for no other (root included unless listed), appending (>>) or writing (>) sshd's drop-in file. A change of the accounts in Beacon then takes this line run again on the machine.
Types ¶
type AccessRuleView ¶
type AccessRuleView struct {
store.AccessRule
Enabled bool `json:"enabled"`
State string `json:"state"`
Direct bool `json:"direct"`
}
AccessRuleView is a rule as the API shows it: State is active, scheduled (before valid_from), expired (after valid_until) or disabled; Enabled the switch.
type Actor ¶
type Actor struct {
Name string
Via string
Key string
Cred string // the credential it came with: token:NAME, grant:ID or key:FINGERPRINT; none for the console and the command line
// From is where it came from: the SSH client's address, or the HTTP client's; invalid when none (the
// command line, a scheduled job). Access rules limited to source addresses check it each time.
From netip.Addr
}
Actor is who uses the channel: Name as the audit log names it (a person, "person / agent", or a token's name), how (ssh, mcp, api, console or cli), and Key, the principal (store.Principal.Key) whose access is checked afresh each time; none for the command line.
type Added ¶
type Added struct {
Machine MachineView `json:"machine"`
// TrustedUserCAKey is the line for the machine's TrustedUserCAKeys file.
TrustedUserCAKey string `json:"trusted_user_ca_key"`
// Setup is what to run on the machine, as root, for a machine Beacon dials: the certificate
// authority, trusted for the machine's accounts alone, and the accounts.
Setup string `json:"setup,omitempty"`
// Connector is the machine-side setup of a machine behind NAT; nil for a machine Beacon dials.
Connector *ConnectorSetup `json:"connector,omitempty"`
}
Added is a machine just added, with what it needs before agents can use it.
type Command ¶
type Command struct {
Command string `json:"command"`
Inputs []string `json:"inputs,omitempty"`
Output string `json:"output"`
Exit *int `json:"exit,omitempty"`
Started time.Time `json:"started"`
Ms int64 `json:"ms"`
Offset float64 `json:"offset"` // where it starts in the recording, in seconds
Risk string `json:"risk,omitempty"` // high when an alert rule matched it
}
Command is one command run at an interactive shell's prompt, as the shell-integration marks delimit it. Inputs are the lines typed into the program while it ran (into psql, say).
type CommandCheck ¶
type CommandCheck struct {
Action string `json:"action"` // block, alert or allow
Rule *store.CommandRule `json:"rule,omitempty"`
}
CommandCheck is which command rule would decide a command: the rule, or none (allowed).
type ConnectorSetup ¶
type ConnectorSetup struct {
// KnownHosts is the line for the machine's known_hosts file: the channel's host key at its public address.
KnownHosts string `json:"known_hosts"`
// Command is the ssh command that connects out; Unit is a systemd unit that keeps it running.
Command string `json:"command"`
Unit string `json:"unit"`
// Script does it all, as root on the machine: the certificate authority, the account, the known_hosts
// line, the connector's key and user, the unit.
Script string `json:"script"`
// HostKeyPending says the machine's host key is not pinned yet: Beacon learns it when the connector
// first connects, and says so in the audit log and the chat.
HostKeyPending bool `json:"host_key_pending,omitempty"`
}
ConnectorSetup is what a machine behind NAT needs on its side, as machine add prints it.
type Deps ¶
type Deps struct {
Store *store.Store
HostKey ssh.Signer // the channel's own host key, which agents' ssh clients pin
CA ssh.Signer // signs the certificates machines accept
// SourceAddresses, when set, go into every certificate as its source-address option (CIDRs), so a
// certificate works only from Beacon's own addresses.
SourceAddresses []string
Dir string // where recordings and transcripts are kept (Files' default)
Keep time.Duration // how long sessions are kept
// Files is where recordings and transcripts are kept: DirFiles under Dir (the default), or an
// S3-compatible bucket an HA pair shares (ssh.recordings: s3 in the configuration).
Files Files
Bot Poster
Lang i18n.Lang
Metrics *metrics.Metrics
Log *slog.Logger
Now func() time.Time
// Dial connects to machines; nil uses a net.Dialer. Tests replace it.
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
// LocalMachines lets whoever may add a machine add one at a loopback or link-local address, as
// beacon on the host may (machine_writes.go). Tests whose machines listen on loopback set it; the
// service never does.
LocalMachines bool
// PublicAddress (host:port) is where agents and connector machines reach the channel; it goes into
// the setup machine add prints for a machine behind NAT. May be empty.
PublicAddress string
// Pages builds the signed links to sessions' pages, where people replay them; nil: no links.
Pages *link.Pages
// Leader reports whether this instance holds the HA lease. Nil means always leader (no HA).
Leader func() bool
// Watermark is where the console's terminal shows a watermark: core (critical machines; the
// default), all or off (config ssh.watermark).
Watermark string
}
Deps are what the channel needs. Bot and Metrics may be nil.
type DirFiles ¶
type DirFiles struct {
Dir string
}
DirFiles keeps recordings under one directory, the default (the data directory's recordings tree). The day's directories are made as needed, and removed when a prune empties them.
func (DirFiles) Create ¶
func (d DirFiles) Create(name string) (io.WriteCloser, error)
Create implements Files.
func (DirFiles) CreateStaged ¶
func (d DirFiles) CreateStaged(name string) (filecapture.Capture, error)
CreateStaged reserves a capture which becomes readable under name on Close.
func (DirFiles) Open ¶
func (d DirFiles) Open(name string) (io.ReadCloser, error)
Open implements Files.
type EditInput ¶
type EditInput struct {
Path string `json:"path"`
OldString string `json:"old_string"`
NewString string `json:"new_string"`
ReplaceAll bool `json:"replace_all,omitempty"`
}
EditInput replaces OldString with NewString in a file: exactly one occurrence, or every one with ReplaceAll.
type FileEntry ¶
type FileEntry struct {
Name string `json:"name"`
Type string `json:"type"` // file, dir, link or other
Size int64 `json:"size"`
Mode string `json:"mode"` // as ls shows it: drwxr-xr-x
Modified time.Time `json:"modified,omitzero"`
}
FileEntry is one entry of a directory.
type FileOp ¶
type FileOp struct {
Op string `json:"op"`
Path string `json:"path"`
To string `json:"to,omitempty"`
Account string `json:"account,omitempty"`
}
FileOp is a change to a machine's files: mkdir, rename (to To) or remove (a file, or an empty directory).
type FileView ¶
type FileView struct {
Machine string `json:"machine"`
Path string `json:"path"`
Content string `json:"content"`
Offset int `json:"offset"`
Lines int `json:"lines"`
TotalLines int `json:"total_lines"`
More bool `json:"more,omitempty"` // lines follow the last one shown
Session string `json:"session"`
RecordingState store.EvidenceState `json:"recording_state,omitempty"`
TranscriptState store.EvidenceState `json:"transcript_state,omitempty"`
}
FileView is part of a file, as an agent's own read tool shows it: each line numbered, a tab, the line.
type Files ¶
type Files interface {
// Create makes the file and returns its writer. A recording's name is its session's id, so a
// file of that name is not expected to exist.
Create(name string) (io.WriteCloser, error)
// WriteFile stores b under the name in one piece (a transcript).
WriteFile(name string, b []byte) error
// ReadFile returns what WriteFile stored.
ReadFile(name string) ([]byte, error)
// Open streams what is under the name (a recording's replay).
Open(name string) (io.ReadCloser, error)
// Remove deletes the file.
Remove(name string) error
}
Files is one recordings store. A file that is not there reads as an error naming it; removing one that is not there is no error.
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
Gate is the SSH channel.
func (*Gate) Access ¶
func (g *Gate) Access(who Actor, key string) (SubjectAccess, error)
Access is what the subject key (user:NAME, agent:NAME, token:NAME; none: who itself) reaches now. Only who itself, a person with machines:write or beacon on the host may ask about another.
func (*Gate) AccessRule ¶
func (g *Gate) AccessRule(id string) (AccessRuleView, error)
AccessRule returns one access rule.
func (*Gate) AccessRules ¶
func (g *Gate) AccessRules() []AccessRuleView
AccessRules lists the access rules.
func (*Gate) CAPublicKey ¶
CAPublicKey is the line machines put in their TrustedUserCAKeys file.
func (*Gate) ChangeFiles ¶
ChangeFiles makes a directory, renames or removes, as account; the operation is recorded.
func (*Gate) CheckCommand ¶
func (g *Gate) CheckCommand(key, machine, command string) (CommandCheck, error)
CheckCommand says what the command rules would do with a command by subject key on machine.
func (*Gate) CheckSSH ¶
func (g *Gate) CheckSSH(ctx context.Context, who Actor, machine, registration string) (SSHCheck, error)
CheckSSH checks a single enrolled machine through the ordinary SSH authorization and pause policy. A nonempty registration binds the console form to the page that offered the check.
func (*Gate) CommandRecords ¶
func (g *Gate) CommandRecords(p store.Principal, f store.RecordFilter) ([]store.CommandRecord, int, error)
CommandRecords lists the command records p may see, newest first, and how many match.
func (*Gate) CommandRule ¶
func (g *Gate) CommandRule(id string) (store.CommandRule, error)
CommandRule returns one command rule.
func (*Gate) CommandRules ¶
func (g *Gate) CommandRules() []store.CommandRule
CommandRules lists the command rules in the order they are applied.
func (*Gate) ConnectionConfig ¶
ConnectionConfig returns a personal connection's SSH configuration and the channel's public host key.
func (*Gate) DeleteAccessRule ¶
DeleteAccessRule removes a rule.
func (*Gate) DeleteCommandRule ¶
DeleteCommandRule removes a command rule.
func (*Gate) DeleteMachineGroup ¶
DeleteMachineGroup removes a group with no groups under it; its machines leave it.
func (*Gate) DeleteSchedule ¶
DeleteSchedule removes a schedule: its maker, or a person with machines:write.
func (*Gate) Detail ¶
func (g *Gate) Detail(who Actor, name, address string) (MachineDetail, error)
Detail returns one machine for who; address is where agents reach the channel, for the ssh configuration.
func (*Gate) DownloadFile ¶
func (g *Gate) DownloadFile(ctx context.Context, who Actor, machine, account, file string, size func(int64), w io.Writer) error
DownloadFile streams a file of machine to w, after size tells its length; the transfer is recorded.
func (*Gate) EditFile ¶
func (g *Gate) EditFile(ctx context.Context, who Actor, machine string, in EditInput) (Written, error)
EditFile edits a text file by exact replacement, as an agent's own edit tool does. It fails rather than overwrite a file that changed after it was read.
func (*Gate) ImportMachines ¶
func (g *Gate) ImportMachines(ctx context.Context, who Actor, file []byte, commit bool) (ImportResult, error)
ImportMachines reads a CSV file of machines and checks every row (commit false), or adds those without problems (commit true). Who needs what adding a machine needs (machines:write, access to all machines; an account other than beacon, a person).
func (*Gate) ImportRows ¶
func (g *Gate) ImportRows(ctx context.Context, who Actor, rows []ImportRow, commit bool) (ImportResult, error)
ImportRows is ImportMachines for rows read already (a preview's, which the console sends back in parts to import): each is checked again, its groups by ID, path or name.
func (*Gate) InteractiveShell ¶
func (g *Gate) InteractiveShell(ctx context.Context, who Actor, machineName string, ioStreams ShellIO) (Transcript, error)
InteractiveShell opens a CA-certified PTY shell on machineName for who, recording asciicast v3 replay and OSC 133 command transcripts identically to direct SSH sessions, and immediately revoking the session if access ends or the channel is paused.
func (*Gate) InterruptJobs ¶
func (g *Gate) InterruptJobs()
InterruptJobs marks the jobs that were running when Beacon stopped as interrupted; main calls it at start.
func (*Gate) List ¶
List returns the machines. address is where agents reach the channel (host:port), for the ssh configuration; it may be empty.
func (*Gate) ListFiles ¶
func (g *Gate) ListFiles(ctx context.Context, who Actor, machine, account, dir string) (Listing, error)
ListFiles lists a directory of machine as account (none: the default the rules allow); path empty is the account's home.
func (*Gate) MachineGroups ¶
func (g *Gate) MachineGroups() []MachineGroupView
MachineGroups lists the machine groups, by path.
func (*Gate) MachineHistory ¶
MachineHistory returns the current registration's metadata versions, newest first.
func (*Gate) PausedSince ¶
PausedSince is when the pause started; zero while the channel runs.
func (*Gate) PublicAddress ¶
PublicAddress returns the configured external host:port of the SSH channel.
func (*Gate) Reachers ¶
Reachers lists who reaches the machine now: every person, agent and token of its own that may do something there, and how.
func (*Gate) ReadFile ¶
func (g *Gate) ReadFile(ctx context.Context, who Actor, machine, path string, offset, limit int) (FileView, error)
ReadFile reads lines of a text file, from line offset (1 is the first), at most limit (default 2000). Lines longer than 2000 characters are cut.
func (*Gate) Recheck ¶
Recheck closes at once what is open on the channel (connections and tool calls) for whoever may no longer reach its machine: a token revoked or expired, an agent deleted or given fewer machines or a weaker preset, an OAuth grant revoked, an account disabled or demoted so that its agents lose machines:ssh, a key removed; and on a machine that is gone or no longer the one it was opened on (added again, another account, address or host key). Beacon calls it after each such change, and every minute (Tidy) for what expired. It reports how many it closed.
func (*Gate) Recording ¶
func (g *Gate) Recording(id string) (io.ReadCloser, error)
Recording opens a session's recording (asciicast v3) for a trusted caller.
func (*Gate) RecordingFor ¶
RecordingFor opens a recording only when p may see this session's details.
func (*Gate) Remove ¶
Remove forgets a machine; its sessions stay on record. What is open on it closes, and a connector machine's connection too.
func (*Gate) RestoreMachine ¶
func (g *Gate) RestoreMachine(ctx context.Context, who Actor, name string, in MachineRestore) (MachineView, error)
RestoreMachine copies an earlier snapshot into a fresh version without changing identity fields.
func (*Gate) Run ¶
Run runs a command on a machine, as one of its accounts, in a shell without a terminal.
func (*Gate) RunPending ¶
RunPending publishes sealed evidence when the files store supports it. Every instance runs the worker, including a standby which may have local evidence from an earlier term as primary.
func (*Gate) RunScheduleNow ¶
RunScheduleNow runs a schedule at once, as its maker, outside its times: only its maker asks.
func (*Gate) RunSchedules ¶
RunSchedules runs the schedules that are due, each as its maker; Tidy calls it on the instance that holds the channel.
func (*Gate) SaveAccessRule ¶
func (g *Gate) SaveAccessRule(ctx context.Context, who Actor, r store.AccessRule, ifVersion int64) (AccessRuleView, error)
SaveAccessRule adds a rule (no ID) or replaces one at version ifVersion (0: whatever it is).
func (*Gate) SaveCommandRule ¶
func (g *Gate) SaveCommandRule(ctx context.Context, who Actor, r store.CommandRule, ifVersion int64) (store.CommandRule, error)
SaveCommandRule adds a command rule (no ID) or replaces one at version ifVersion (0: whatever it is).
func (*Gate) SaveMachineGroup ¶
func (g *Gate) SaveMachineGroup(ctx context.Context, who Actor, gr store.MachineGroup) (MachineGroupView, error)
SaveMachineGroup adds a group (no ID) or renames, moves or notes one.
func (*Gate) SaveSchedule ¶
func (g *Gate) SaveSchedule(ctx context.Context, who Actor, s store.JobSchedule, ifVersion int64) (ScheduleView, error)
SaveSchedule adds a schedule (no ID) or changes one at version ifVersion (0: whatever it is). Who makes it runs it; only they change what it runs, and a person with machines:write may switch theirs off or on.
func (*Gate) Schedule ¶
func (g *Gate) Schedule(who Actor, id string) (ScheduleView, error)
Schedule returns one schedule who may see.
func (*Gate) Schedules ¶
func (g *Gate) Schedules(who Actor) ([]ScheduleView, error)
Schedules lists the schedules who may see: their own, or every one for a person with machines:write.
func (*Gate) SearchFiles ¶
func (g *Gate) SearchFiles(ctx context.Context, who Actor, machine string, in SearchInput) (SearchResult, error)
SearchFiles searches a single authorised machine under its ordinary operating-system identity. The directory selects the search, without granting broader access than other file tools.
func (*Gate) SendFile ¶
func (g *Gate) SendFile(ctx context.Context, who Actor, in SendFileInput, content []byte) (store.Job, error)
SendFile starts a job that writes content to each machine and returns it as it starts.
func (*Gate) Serve ¶
Serve answers SSH connections on ln until ln is closed or ctx ends: agents', whose user name is the machine they want, and connector machines', which sign in as themselves (connector.go). Ctx is this instance's hold on the channel: when it ends (the HA lease is lost, or Beacon stops), ln is closed, and so is everything open on the channel here, connections and tool calls alike, so that none outlives the pause switch, revocation and the checks every minute that the instance holding the lease runs.
func (*Gate) Session ¶
func (g *Gate) Session(id string) (Transcript, error)
Session returns a session's transcript for a trusted caller; an open session has only its record.
func (*Gate) SessionCommands ¶
func (g *Gate) SessionCommands(ctx context.Context, p store.Principal, id string) ([]Command, error)
SessionCommands lists a session's commands as p may see them: a shell's from its transcript, with where each starts in the recording and how it ended; a command's own.
func (*Gate) SessionDetail ¶
SessionDetail verifies access to the replay for a caller who has already authorised the session.
func (*Gate) SessionDetailFor ¶
func (g *Gate) SessionDetailFor(ctx context.Context, p store.Principal, id string) (Transcript, error)
SessionDetailFor verifies the replay only after checking the caller's machine and session scope.
func (*Gate) SessionFor ¶
SessionFor returns a transcript only when p may see this session's details.
func (*Gate) SessionTransfers ¶
SessionTransfers lists a session's file transfers as p may see them.
func (*Gate) Sessions ¶
func (g *Gate) Sessions(f SessionFilter) ([]SessionView, error)
Sessions lists sessions for a trusted caller, newest first.
func (*Gate) SessionsFor ¶
func (g *Gate) SessionsFor(p store.Principal, f SessionFilter) ([]SessionView, error)
SessionsFor lists sessions visible to p. The machine scope is applied before the result limit.
func (*Gate) SetConnector ¶
SetConnector sets or changes the key a connector machine connects out with. A connection signed in with the old key is closed.
func (*Gate) SetGroupMachines ¶
func (g *Gate) SetGroupMachines(ctx context.Context, who Actor, id string, add, remove []string) (MachineGroupView, error)
SetGroupMachines puts machines in a group (add) and takes others out of it (remove), each a change of that machine's settings, in its history.
func (*Gate) SetLeader ¶
SetLeader sets how the channel tells whether this instance holds the HA lease. main calls it after the lease exists; newGate runs earlier. Nil means always leader (no HA).
func (*Gate) SetPaused ¶
SetPaused pauses or resumes access. Pausing closes every open client connection and tool call; resuming takes a person or beacon on the host (mayResume).
func (*Gate) SetWatermark ¶
SetWatermark sets where the console's terminal shows a watermark: core, all or off.
func (*Gate) StartJob ¶
StartJob starts a job and returns it as it starts. Each machine's run is checked, run and recorded as run_command's is: one the caller may not run on is refused, with the reason, and the others go on.
func (*Gate) StopJob ¶
StopJob stops a running job: what still runs on its machines is killed, and what has not started does not. Its own principal stops it, or a person with machines:write who may see it.
func (*Gate) Terminate ¶
Terminate ends a live session at once, for reason: what it runs on the machine is closed, its record says who ended it and why, the audit log and the chat hear of it. It takes a person with machines:write who may see the session, or the principal the session is (its own work), or beacon on the host.
func (*Gate) Tidy ¶
Tidy keeps the channel tidy until ctx ends: it forgets sessions older than Keep, with their files, and sends the chat what agents did.
func (*Gate) TidyMachineAccess ¶
TidyMachineAccess forgets the named machines whose access ended, on every credential and account, each in the audit log (store.TidyMachineAccess). Their access ended when the time came; Recheck closes what is open on them.
func (*Gate) TransferRecords ¶
func (g *Gate) TransferRecords(p store.Principal, f store.RecordFilter) ([]store.TransferRecord, int, error)
TransferRecords lists the file transfers p may see, newest first, and how many match.
func (*Gate) Update ¶
func (g *Gate) Update(ctx context.Context, who Actor, name string, in MachineUpdate) (MachineView, error)
Update patches machine metadata and records any resulting revision.
func (*Gate) UpdateSettings ¶
func (g *Gate) UpdateSettings(publicAddr string, sourceAddrs []string, keep time.Duration, lang i18n.Lang, bot Poster)
UpdateSettings updates runtime SSH settings without interrupting active sessions.
func (*Gate) UploadFile ¶
func (g *Gate) UploadFile(ctx context.Context, who Actor, machine, account, file string, r io.Reader) (int64, error)
UploadFile writes r to a file of machine, replacing it; the transfer is recorded.
func (*Gate) WaitJob ¶
func (g *Gate) WaitJob(ctx context.Context, p store.Principal, id string, d time.Duration) (store.Job, error)
WaitJob waits until the job ends, or d passes, or ctx ends, and returns it as it then stands.
func (*Gate) Watch ¶
func (g *Gate) Watch(ctx context.Context, p store.Principal, id string) (LiveHeader, <-chan LiveEvent, error)
Watch follows a live session that p may see in detail: the header, then the output so far (up to liveBacklog), then each event as it comes, ending with end. The channel closes when the session ends, ctx ends, or the watcher falls behind.
type ImportResult ¶
type ImportResult struct {
Committed bool `json:"committed"`
Rows []ImportRow `json:"rows"`
Ready int `json:"ready"`
Problems int `json:"problems"`
Added int `json:"added"`
Failed int `json:"failed"`
}
ImportResult is a file previewed or imported: its rows and how many are in each state.
type ImportRow ¶
type ImportRow struct {
Line int `json:"line"`
Name string `json:"name"`
Address string `json:"address"`
Accounts []store.MachineAccount `json:"accounts,omitempty"`
Groups []string `json:"groups,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Note string `json:"note,omitempty"`
State string `json:"state"`
Problems []string `json:"problems,omitempty"`
Error string `json:"error,omitempty"`
Code string `json:"code,omitempty"`
// Next is what remains on a machine added: the lines to run on it as root (Setup), or, behind NAT,
// the connector's script to run there once its key is set.
Setup string `json:"setup,omitempty"`
Connector *ConnectorSetup `json:"connector,omitempty"`
HostKey string `json:"host_key_fingerprint,omitempty"`
}
ImportRow is one row of the file as Beacon reads it, and what became of it. State is ready (it can be added), problem (Problems say why), added (Next says what remains on the machine) or failed (Error says why: the machine could not be reached, say).
type JobFilter ¶
JobFilter narrows a list of jobs: State, Actor (RanBy) and Schedule (the runs of one).
type JobInput ¶
type JobInput struct {
Command string `json:"command"`
Machines []string `json:"machines,omitempty"`
Groups []string `json:"groups,omitempty"`
Account string `json:"account,omitempty"`
Cwd string `json:"cwd,omitempty"`
Timeout int `json:"timeout,omitempty"`
Background bool `json:"-"`
// contains filtered or unexported fields
}
JobInput starts a job: the command, the machines it runs on (named, and every machine in the groups that the caller reaches), the account, and how long each machine's run may take (seconds).
type Listing ¶
type Listing struct {
Machine string `json:"machine"`
Account string `json:"account"`
Path string `json:"path"`
Entries []FileEntry `json:"entries"`
Session string `json:"session"`
}
Listing is a directory: its path, as the machine resolves it, and its entries, directories first.
type LiveEvent ¶
type LiveEvent struct {
Type string `json:"type"`
T float64 `json:"t"`
Data string `json:"data,omitempty"`
}
LiveEvent is one event of a live session as a watcher gets it: o output, r a resize ("COLSxROWS"), m a command starting (the command), x the exit status, and end when the session ends. T is seconds since the session started, as in its recording.
type LiveHeader ¶
type LiveHeader struct {
Type string `json:"type"` // header
Session store.SessionRecord `json:"session"`
Cols int `json:"cols"`
Rows int `json:"rows"`
}
LiveHeader is what a watcher gets first: the session and its terminal's size.
type MachineDetail ¶
type MachineDetail struct {
Machine MachineView
SSHConfig string
KnownHosts string
Setup string
Connector *ConnectorSetup
}
MachineDetail is one machine as its page shows it: the machine, how the caller connects to it with its own ssh (when it may), and what the machine needs to trust Beacon.
type MachineGroupView ¶
type MachineGroupView struct {
store.MachineGroup
Path string `json:"path"`
Machines int `json:"machines"`
}
MachineGroupView is a machine group as the API shows it: its path from the top and how many machines sit in it directly.
type MachineInput ¶
type MachineInput struct {
Name string `json:"name"`
Address string `json:"address"`
User string `json:"user,omitempty"`
Critical bool `json:"critical,omitempty"`
Note string `json:"note,omitempty"`
Replace bool `json:"replace,omitempty"`
ConnectorKey string `json:"connector_key,omitempty"`
HostKey string `json:"host_key,omitempty"`
// Accounts are the machine's accounts (the first the default, unless User names another); Platform
// linux or other; Labels its labels; Groups the machine groups it sits in.
Accounts []store.MachineAccount `json:"accounts,omitempty"`
Platform string `json:"platform,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Groups []string `json:"groups,omitempty"`
// contains filtered or unexported fields
}
MachineInput adds a machine. Address is host or host:port (22 by default), or "connector" for a machine behind NAT that connects out to the channel itself; User defaults to beacon. Replace registers the machine again, pinning its host key again after it was reinstalled, say; like every other change of a machine it takes access to all machines (machine_writes.go). ConnectorKey is the public key a connector machine signs in with, and HostKey its sshd's host key, which Beacon otherwise learns the first time the machine connects; both are for connector machines only.
type MachineRestore ¶
type MachineUpdate ¶
type MachineUpdate = store.MachineMetadataUpdate
MachineUpdate changes only the restorable metadata. A nil field keeps the current value.
type MachineView ¶
type MachineView struct {
Name string `json:"name"`
Version int64 `json:"metadata_version"`
Registration string `json:"-"`
MonitorRegistration string `json:"registration,omitempty"`
Address string `json:"address"`
User string `json:"user"` // the default account
HostKey string `json:"host_key_fingerprint"`
Critical bool `json:"critical,omitempty"`
Note string `json:"note,omitempty"`
Added time.Time `json:"added"`
AddedBy string `json:"added_by,omitempty"`
// Accounts are the machine's accounts, the default first; Platform linux or other; Labels its
// labels; Groups the IDs of the machine groups it sits in.
Accounts []store.MachineAccount `json:"accounts"`
Platform string `json:"platform"`
Labels map[string]string `json:"labels"`
Groups []string `json:"groups"`
// Reachable says whether the caller reaches it through the channel; Access what the caller may do
// there, account by account.
Reachable bool `json:"reachable"`
Access []store.AccountGrant `json:"access"`
// Connector says the machine connects out to the channel itself (behind NAT); Connected and
// ConnectedSince say whether and since when it is connected right now. Both are left out for
// machines Beacon dials.
Connector bool `json:"connector,omitempty"`
Connected *bool `json:"connected,omitempty"`
ConnectedSince time.Time `json:"connected_since,omitzero"`
}
MachineView is a machine as the API shows it.
type Machines ¶
type Machines struct {
Machines []MachineView `json:"machines"`
// SSHConfig is an ssh_config(5) block for the machines the caller reaches, with the channel's host
// key for known_hosts; empty without Address.
SSHConfig string `json:"ssh_config,omitempty"`
KnownHosts string `json:"known_hosts,omitempty"`
}
Machines is the list of machines, and how the caller connects to them with its own ssh.
type Reach ¶
type Reach struct {
Machine string `json:"machine"`
Critical bool `json:"critical,omitempty"`
Access []store.AccountGrant `json:"access"`
Rules []string `json:"rules"`
}
Reach is what a subject may do on one machine: each account and its actions, and the rules that give it (the subject's own layer: an agent's rules, not its owner's).
type Reacher ¶
type Reacher struct {
Subject string `json:"subject"` // user:NAME, agent:NAME or token:NAME
Name string `json:"name"`
Kind string `json:"kind"` // person, agent or token
Owner bool `json:"owner,omitempty"`
Access []store.AccountGrant `json:"access"`
Rules []string `json:"rules"`
}
Reacher is a subject that reaches a machine: who, what as, and through which rules.
type RunInput ¶
type RunInput struct {
Command string `json:"command"`
Cwd string `json:"cwd,omitempty"`
Stdin string `json:"stdin,omitempty"`
Timeout int `json:"timeout,omitempty"`
Account string `json:"account,omitempty"`
}
RunInput runs a command. Timeout is in seconds (default 120, at most 600). Account is the machine's account to run it as; none is the default one the access rules allow.
type RunResult ¶
type RunResult struct {
Machine string `json:"machine"`
Account string `json:"account,omitempty"`
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
TimedOut bool `json:"timed_out,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Ms int64 `json:"duration_ms"`
Session string `json:"session"`
RecordingState store.EvidenceState `json:"recording_state,omitempty"`
TranscriptState store.EvidenceState `json:"transcript_state,omitempty"`
}
RunResult is what a command did. ExitCode is -1 when it timed out.
type SSHCheck ¶
type SSHCheck struct {
ID string `json:"check_id"`
Machine string `json:"machine"`
Route string `json:"route"`
Status SSHCheckStatus `json:"status"`
CheckedAt time.Time `json:"checked_at"`
}
SSHCheck reports a point-in-time attempt by Beacon. Ready means the pinned key matched and the machine accepted Beacon's certificate. The check never asks the machine to open a session.
type SSHCheckStatus ¶
type SSHCheckStatus string
SSHCheckStatus describes which part of the machine handshake Beacon observed.
const ( SSHCheckReady SSHCheckStatus = "ready" SSHCheckDisconnected SSHCheckStatus = "connector_disconnected" SSHCheckConnectorBusy SSHCheckStatus = "connector_busy" SSHCheckForwardFailed SSHCheckStatus = "connector_forward_failed" SSHCheckUnreachable SSHCheckStatus = "unreachable" SSHCheckHostKeyMismatch SSHCheckStatus = "host_key_mismatch" SSHCheckHandshakeFailed SSHCheckStatus = "handshake_failed" SSHCheckAuthenticationIncomplete SSHCheckStatus = "authentication_incomplete" SSHCheckAuthenticationSkipped SSHCheckStatus = "authentication_skipped" SSHCheckTimedOut SSHCheckStatus = "timed_out" )
type ScheduleView ¶
type ScheduleView struct {
store.JobSchedule
Running bool `json:"running,omitempty"`
}
ScheduleView is a schedule as the API shows it: whether its last run is still going.
type SearchInput ¶
type SearchInput struct {
Directory string `json:"directory" jsonschema:"absolute physical project directory"`
Query string `json:"query" jsonschema:"literal case-sensitive text on one line"`
Limit int `json:"limit,omitempty" jsonschema:"maximum matches (default 25, maximum 50)"`
}
SearchInput asks for literal, case-sensitive matches in an explicit project directory.
type SearchMatch ¶
type SearchResult ¶
type SearchResult struct {
Machine string `json:"machine"`
Directory string `json:"directory"`
Matches []SearchMatch `json:"matches"`
ScannedFiles *int `json:"scanned_files,omitempty"`
Limited bool `json:"limited"`
TimedOut bool `json:"timed_out,omitempty"`
Session string `json:"session"`
RecordingState store.EvidenceState `json:"recording_state,omitempty"`
TranscriptState store.EvidenceState `json:"transcript_state,omitempty"`
}
type SendFileInput ¶
type SendFileInput struct {
Name string `json:"name"`
Path string `json:"path"`
Machines []string `json:"machines,omitempty"`
Groups []string `json:"groups,omitempty"`
Account string `json:"account,omitempty"`
}
SendFileInput sends a file: the machines (named, and those in the groups that the caller reaches), the account, and the path on each, a directory when it ends in a slash (the file keeps its name).
type SessionFilter ¶
type SessionFilter struct {
Machine string
Agent string
Limit int
// State is live (open now) or ended; Kind exec, shell, sftp, forward, file…; Risk high; From and To
// bound when it started; Before is a session ID to list from (the next page).
State, Kind, Risk string
From, To time.Time
Before string
}
SessionFilter narrows a list of sessions. Agent matches who ran them: "person / agent", the agent or the person alone, or a token's name.
type SessionView ¶
type SessionView struct {
store.SessionRecord
Page string `json:"page,omitempty"`
Live bool `json:"live"`
}
SessionView is a session as the API and MCP list it: its record, the link to its page, and whether it is open now.
type ShellEvent ¶
ShellEvent carries terminal stdin bytes or a dynamic PTY window resize from an interactive client. Paste marks input the person pasted, which the access rules' paste action must allow.
type ShellIO ¶
type ShellIO struct {
Cols, Rows int
Account string // the machine's account to sign in as; none: the default one the rules allow
OnStart func(sessionID string)
Started func(ShellStart) // the session as it starts, after OnStart
Output func(data []byte) error
Events <-chan ShellEvent
}
ShellIO connects an interactive terminal frontend (such as the console's WebSocket terminal) to a recorded, CA-certified PTY shell session on an enrolled machine.
type ShellStart ¶
ShellStart is a terminal's session as it starts: its ID, the machine and the account signed in as, whether the access rules let the person copy from it and paste into it (the console's terminal enforces both), and the name to show over it as a watermark (none: no watermark).
type SubjectAccess ¶
type SubjectAccess struct {
Subject string `json:"subject"`
Name string `json:"name"`
Every bool `json:"every,omitempty"` // an owner: every machine, as every account
All bool `json:"all,omitempty"` // every machine that is not critical, machines added later included
Machines []Reach `json:"machines"`
}
SubjectAccess is what a subject reaches now.
type Transcript ¶
type Transcript struct {
store.SessionRecord
Stdin string `json:"stdin,omitempty"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
Commands []Command `json:"commands,omitempty"`
CommandsAdvisory bool `json:"commands_advisory,omitempty"`
Truncated bool `json:"truncated,omitempty"` // the recording or structured text exceeded its capture limit
Page string `json:"page,omitempty"`
RecordingAvailable *bool `json:"recording_available,omitempty"`
RecordingPublication string `json:"recording_publication,omitempty"`
TranscriptPublication string `json:"transcript_publication,omitempty"`
// contains filtered or unexported fields
}
Transcript is a session as an agent reads it back: the record, plus what a command was sent and printed (cleaned of terminal codes) or, for an interactive shell, each command with its output and exit status. A shell's commands are told apart by the shell-integration marks in its output, which any program the shell runs can print too, so CommandsAdvisory says they are a guide; the recording, with what was typed and the raw output, is the record. Page is the session's replay URL.
type Written ¶
type Written struct {
Machine string `json:"machine"`
Path string `json:"path"`
Bytes int `json:"bytes"`
Replacements int `json:"replacements,omitempty"`
Session string `json:"session"`
RecordingState store.EvidenceState `json:"recording_state,omitempty"`
TranscriptState store.EvidenceState `json:"transcript_state,omitempty"`
}
Written is what a write or an edit did.