Documentation
¶
Overview ¶
Package events tracks the files authama is responsible for - everything under ~/.ssh, the config home, and each tool's credential file - and records every change to them, whoever made it: authama, an editor, ssh-keygen run by hand, a package manager rewriting its token file.
It never records a file's contents. Each scan keeps, per file, its size, mode, modification time and a SHA-256 of its bytes, in an owner-only state file; an event names the file, what changed (added, changed, removed, mode) and when it was seen. The hash detects a change and cannot be turned back into a key or a token.
Index ¶
Constants ¶
const ( AreaSSH = "ssh" // under ~/.ssh AreaConfig = "config" // the config home: manifest, inventory, settings, .env AreaAuth = "auth" // a tool's credential file: auth.json, .npmrc, … )
The areas a tracked file belongs to.
const ( KindStarted = "started" // the first scan: tracking began, nothing compared KindAdded = "added" KindChanged = "changed" // the contents changed KindRemoved = "removed" KindMode = "mode" // only the permissions changed )
The kinds of event.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Event ¶
type Event struct {
Time time.Time `json:"time"`
Seen time.Time `json:"seen"`
Kind string `json:"kind"`
Area string `json:"area"`
Path string `json:"path"`
Size int64 `json:"size,omitempty"`
Mode string `json:"mode,omitempty"`
Detail string `json:"detail,omitempty"`
// Hash chains the log: SHA-256 of the previous line's Hash and this
// event's other fields. An edited, removed or inserted line breaks the
// chain from there on (see Verify).
Hash string `json:"hash,omitempty"`
}
Event is one change seen by a scan. Time is when the change happened as far as the file says - its modification time, for an added or changed file - and Seen is the scan that found it; a removal or a mode change, which leaves no time behind, has Time equal to Seen.
type Integrity ¶
type Integrity struct {
Lines int // lines read
Chained int // lines carrying a hash
Unchained int // lines from before the log was chained, at its start
Broken int // the first line (1-based) whose hash does not follow, 0 when none
Reason string // why, when Broken or Truncated
Truncated bool // the log ends before the head the state recorded
}
Integrity is what Verify found.
func Verify ¶
Verify checks the events log's hash chain: every chained line must hash from the one before it, and the last must be the head the state recorded. Lines written before the log was chained, at its start, are counted, not checked. Tamper evidence, not proof: someone who can rewrite the state home can rewrite both files, but not one line without the chain showing it.