Documentation
¶
Overview ¶
Package audit 记录守卫侧的安全事件。
审计的权威存储在扩展侧;本包记录 daemon 本地观察到的握手、配对、Origin 拒绝和限流事件, 补足未转发到扩展的安全信号,边界见 docs/threat-model.md。
事件只有固定字段(类型 / 客户端标识 / 原因分类),没有承载任意载荷的出口,以此保证 安全约束见 docs/threat-model.md:token 原文、脚本源码、含凭据的 URL 永不进入审计与日志。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
At time.Time `json:"at"`
Type Type `json:"type"`
Client string `json:"client,omitempty"`
Reason Reason `json:"reason,omitempty"`
}
Event 是一条安全事件。字段集合是封闭的(见包注释)。
type Reason ¶
type Reason string
Reason 是失败原因分类。刻意用固定枚举而非原始错误串,避免错误信息把敏感内容带进审计。
const ( ReasonHMACMismatch Reason = "hmac_mismatch" ReasonTimeout Reason = "timeout" ReasonProtocol Reason = "protocol_violation" ReasonPairExpired Reason = "pairing_expired" ReasonPairExhausted Reason = "pairing_attempts_exhausted" // ReasonUnknownInstance 表示声明的浏览器实例未配对(或已被忘记)。 ReasonUnknownInstance Reason = "unknown_instance" )
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder 是固定容量的事件环形缓冲,同时把每条事件结构化输出到日志。 可查询的这份只驻内存(daemon 重启即清空);日志那份随 <dataDir>/logs 落盘, 两个出口都靠上面封闭的字段集合保证不含敏感内容。
func NewRecorder ¶
NewRecorder 构造容量为 capacity 的记录器。