Documentation
¶
Index ¶
- Constants
- func IsTransactionCommand(sql string) (bool, string)
- type MySQLQuery
- type MySQLRecorder
- func (r *MySQLRecorder) GetCurrentDatabase() string
- func (r *MySQLRecorder) GetQueries() []*MySQLQuery
- func (r *MySQLRecorder) GetQueryCount() int
- func (r *MySQLRecorder) Protocol() audit.Protocol
- func (r *MySQLRecorder) RecordQuery(timestamp float64, sql string, riskLevel string, blocked bool) error
- func (r *MySQLRecorder) RecordTransactionEnd(timestamp float64, txType string) error
- func (r *MySQLRecorder) RecordTransactionStart(timestamp float64) error
- func (r *MySQLRecorder) SetCurrentDatabase(database string)
- func (r *MySQLRecorder) Start(ctx context.Context, sessionID string, metadata map[string]interface{}) error
- func (r *MySQLRecorder) Status() RecordingStatus
- func (r *MySQLRecorder) Stop(ctx context.Context) (string, error)
- func (r *MySQLRecorder) UpdateQueryResult(queryIndex int, result string, duration float64, rowsAffected int64, err error) error
- func (r *MySQLRecorder) Write(timestamp float64, ioType rune, data []byte) error
- type MySQLRecordingMetadata
- type Recorder
- type RecorderFactory
- type RecordingStatus
Constants ¶
View Source
const ( RecordingStatusActive = proxy.RecordingStatusActive RecordingStatusRecording = proxy.RecordingStatusRecording RecordingStatusPaused = proxy.RecordingStatusPaused RecordingStatusStopped = proxy.RecordingStatusStopped )
Variables ¶
This section is empty.
Functions ¶
func IsTransactionCommand ¶
IsTransactionCommand 判断是否是事务命令
Types ¶
type MySQLQuery ¶
type MySQLQuery struct {
Timestamp float64 `json:"timestamp"` // 相对时间(秒)
SQL string `json:"sql"` // SQL 语句
RiskLevel string `json:"risk_level"` // 风险级别
Blocked bool `json:"blocked"` // 是否被阻断
Result string `json:"result"` // 执行结果
Duration float64 `json:"duration,omitempty"` // 执行耗时(毫秒)
RowsAffected int64 `json:"rows_affected,omitempty"` // 影响行数
Error string `json:"error,omitempty"` // 错误信息
}
MySQLQuery MySQL 查询记录
type MySQLRecorder ¶
type MySQLRecorder struct {
// contains filtered or unexported fields
}
MySQLRecorder MySQL 录制器(JSON 格式)
func NewMySQLRecorder ¶
func NewMySQLRecorder(storage audit.ObjectStorage) *MySQLRecorder
NewMySQLRecorder 创建 MySQL 录制器
func (*MySQLRecorder) GetCurrentDatabase ¶
func (r *MySQLRecorder) GetCurrentDatabase() string
GetCurrentDatabase 获取当前数据库
func (*MySQLRecorder) GetQueries ¶
func (r *MySQLRecorder) GetQueries() []*MySQLQuery
GetQueries 获取所有查询记录
func (*MySQLRecorder) GetQueryCount ¶
func (r *MySQLRecorder) GetQueryCount() int
GetQueryCount 获取查询数量
func (*MySQLRecorder) RecordQuery ¶
func (r *MySQLRecorder) RecordQuery(timestamp float64, sql string, riskLevel string, blocked bool) error
RecordQuery 记录 SQL 查询
func (*MySQLRecorder) RecordTransactionEnd ¶
func (r *MySQLRecorder) RecordTransactionEnd(timestamp float64, txType string) error
RecordTransactionEnd 记录事务结束
func (*MySQLRecorder) RecordTransactionStart ¶
func (r *MySQLRecorder) RecordTransactionStart(timestamp float64) error
RecordTransactionStart 记录事务开始
func (*MySQLRecorder) SetCurrentDatabase ¶
func (r *MySQLRecorder) SetCurrentDatabase(database string)
SetCurrentDatabase 设置当前数据库(追踪 USE database 命令)
func (*MySQLRecorder) Start ¶
func (r *MySQLRecorder) Start(ctx context.Context, sessionID string, metadata map[string]interface{}) error
Start 开始录制
func (*MySQLRecorder) Stop ¶
func (r *MySQLRecorder) Stop(ctx context.Context) (string, error)
Stop 停止录制
func (*MySQLRecorder) UpdateQueryResult ¶
func (r *MySQLRecorder) UpdateQueryResult(queryIndex int, result string, duration float64, rowsAffected int64, err error) error
UpdateQueryResult 更新查询结果
type MySQLRecordingMetadata ¶
type MySQLRecordingMetadata struct {
Version int `json:"version"`
SessionID string `json:"session_id"`
StartTime time.Time `json:"start_time"`
Database string `json:"database,omitempty"`
User string `json:"user,omitempty"`
Queries []*MySQLQuery `json:"queries"`
}
MySQLRecordingMetadata MySQL 录制元数据
type RecorderFactory ¶
type RecorderFactory = proxy.RecorderFactory
Click to show internal directories.
Click to hide internal directories.