Documentation ¶
Overview ¶
Package auditlog implements auditable logs for recording security events. The logs are currently backed by SQLite3. They are designed to form a chain of auditable, tamper-evident logs. The chain is a tree of signatures where the signature on each event is computed over both the event and the previous event's signature.
The audit logger is concerned with events. For example, an event might be recorded when a user logs in, or an administrative action is carried out.
Index ¶
- type Attribute
- type Certification
- type DBConnDetails
- type ECDSASignature
- type ErrorEvent
- type Event
- type Logger
- func (l *Logger) Certify(start, end uint64) ([]byte, error)
- func (l *Logger) Count() uint64
- func (l *Logger) CriticalSync(actor, event string, attributes []Attribute)
- func (l *Logger) Debug(actor, event string, attributes []Attribute)
- func (l *Logger) Error(actor, event string, attributes []Attribute)
- func (l *Logger) ErrorSync(actor, event string, attributes []Attribute)
- func (l *Logger) Info(actor, event string, attributes []Attribute)
- func (l *Logger) InfoSync(actor, event string, attributes []Attribute)
- func (l *Logger) Public() ([]byte, error)
- func (l *Logger) RootSignature() ([]byte, error)
- func (l *Logger) Start() error
- func (l *Logger) Stop()
- func (l *Logger) Warning(actor, event string, attributes []Attribute)
- func (l *Logger) WarningSync(actor, event string, attributes []Attribute)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
An Attribute is used to encode additional details about an event. An example attribute might be
Attribute{ Name: "user", Value: "root", }
type Certification ¶
type Certification struct { When int64 `json:"when"` Chain []*Event `json:"chain"` Errors []*ErrorEvent `json:"errors"` }
A Certification contains a snapshot an audit chain, errors that occurred in the range of events, and a nanosecond-resolution timestamp of when the certification was built.
func VerifyCertification ¶
func VerifyCertification(in []byte, signer *ecdsa.PublicKey) (*Certification, bool)
VerifyCertification verifies a JSON-encoded certification against the signer's public key.
type DBConnDetails ¶
DBConnDetails contains the connection parameters for the database.
func (DBConnDetails) String ¶
func (cd DBConnDetails) String() string
type ECDSASignature ¶
An ECDSASignature is the structure into which an ECDSA signature is packed.
type ErrorEvent ¶
type ErrorEvent struct { When int64 `json:"when"` Message string `json:"message"` Event *Event `json:"event"` }
An ErrorEvent is stored in the error log; these are used to record a failure of the auditor to sign and store an event. The event contained in the ErrorEvent stores the serial number the event would have been assigned, which will be reused by future events. These are recorded on the following failures: database failures (failure to begin or commit a transaction, or when the database returns a failure), and failure to compute a signature.
type Event ¶
type Event struct { // Serial is the event's position in the audit chain. Serial uint64 // When is a nanosecond-resolution timestamp recording when // the event was logged. When int64 // Received is a nanosecond-resolution timestamp recording // when the event was processed by the audit logger. Received int64 // Level contains a text description inidicating the log // level; this is currently defined as one of the strings // "DEBUG", "INFO", "WARNING", "ERROR", or "CRITICAL". Level string // Actor indicates the component that reported the event. Actor string // Event contains a text description of the event that // occurred. Event string // Attributes is an (optional) list of additional details that // may be relevant to the event. Attributes []Attribute // Signature contains the audit logger's ECDSA signature on // the event. This signature is computed on the SHA-256 digest // of all the other fields in the event and the previous event // in the chain's signature. Signature []byte // contains filtered or unexported fields }
An Event captures information about an event.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger is responsible for recording security events.
func New ¶
func New(cd *DBConnDetails, signer *ecdsa.PrivateKey) (*Logger, error)
New sets up a new logger, using the signer for signatures and backed by the database at the specified file. If the database exists, the audit chain will be verified.
func (*Logger) Certify ¶
Certify returns a certification for the requested range of events; start and end are event serial numbers. The certification is returned in JSON.
func (*Logger) CriticalSync ¶
CriticalSync records a critical failure of this system. This is almost always followed by a shutdown, and therefore only a synchronous version that waits for the event to be recorded is provided.
func (*Logger) Debug ¶
Debug records a debug event. In practice, this should not be used; it is intended only for debugging the audit logger. This does not wait for the audit logger to finish recording the event.
func (*Logger) Error ¶
Error records an error event. An example might be an authentication failure. This does not wait for the audit logger to finish recording the event.
func (*Logger) ErrorSync ¶
ErrorSync performs the same function as error, except it waits for the event to be recorded.
func (*Logger) Info ¶
Info records an informational event. This probably includes events that are expected normally. This does not wait for the audit logger to finish recording the event.
func (*Logger) InfoSync ¶
InfoSync performs the same function as Info, except it waits for the event to be recorded.
func (*Logger) Public ¶
Public returns the public signature key packed as in DER-encoded PKIX format.
func (*Logger) RootSignature ¶
RootSignature returns the signature of the root event (i.e. the event with serial = 0). The user can store a copy of this, and use it to ensure the root of the chain has not been tampered with.
func (*Logger) Start ¶
Start starts up the audit logger. This must be called prior to logging events.
func (*Logger) Stop ¶
func (l *Logger) Stop()
Stop halts the logger and cleanly shuts down the database connection.
func (*Logger) Warning ¶
Warning records an event that isn't an error, but it is a more urgent event. Examples of warning events might be users selecting a deprecated cipher. This does not wait for the audit logger to finish recording the event.
func (*Logger) WarningSync ¶
WarningSync performs the same function as Warning, except it waits for the event to be recorded.