audit

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2025 License: MIT Imports: 9 Imported by: 0

README

审计模块

Documentation

Index

Constants

View Source
const (
	META_AUDIT_KEY = "audit"
)
View Source
const (
	PRIORITY = 90
)

Variables

View Source
var (
	AppName = "audits"
)

Functions

This section is empty.

Types

type AuditLog

type AuditLog struct {
	// 事件Id,
	Id string `json:"id" gorm:"primaryKey;column:id"`
	// 谁
	Who string `json:"who" gorm:"column:who"`
	// 在什么时间
	Time int64 `json:"time" gorm:"column:time"`
	// 操作人的Ip
	Ip string `json:"ip" gorm:"column:ip"`
	// User Agent
	UserAgent string `json:"user_agent" gorm:"column:user_agent"`

	// 做了什么操作,  服务:资源:动作
	// 服务 <cmdb, mcenter, ....>
	Service string `json:"service" gorm:"column:service"`
	// 哪个空间
	Namespace string `json:"namespace" gorm:"column:namespace"`
	// 资源 <secret, user, namespace, ...>
	ResourceType string `json:"resource_type" gorm:"column:resource_type"`
	// 动作 <list, get, update, create, delete, ....>
	Action string `json:"action" gorm:"column:action"`

	// 详情信息
	ResourceId string `json:"resource_id" gorm:"column:resource_id"`
	// 状态码 404
	StatusCode int `json:"status_code" gorm:"column:status_code"`
	// 具体信息
	ErrorMessage string `json:"error_message" gorm:"column:error_message"`

	// 标签
	Label map[string]string `json:"label" gorm:"column:label;serializer:json;type:json" description:"事件标签" optional:"true"`
	// 扩展信息
	Extras map[string]string `json:"extras" gorm:"column:extras;serializer:json;type:json" description:"额外属性" optional:"true"`
}

用户操作事件 如何映射成 MongoDB BSON

func NewAuditLog

func NewAuditLog() *AuditLog

func (*AuditLog) Load

func (e *AuditLog) Load(data []byte) error

func (*AuditLog) String

func (e *AuditLog) String() string

func (*AuditLog) TableName

func (e *AuditLog) TableName() string

func (*AuditLog) ToBusEvent

func (e *AuditLog) ToBusEvent(topic string) *bus.Event

type QueryAuditLogRequest

type QueryAuditLogRequest struct {
	// 分页请求参数
	*request.PageRequest
	// 事件标签, TaskId
	Label map[string]string `json:"label" bson:"label" description:"事件标签" optional:"true"`
}

func NewQueryAuditLogRequest

func NewQueryAuditLogRequest() *QueryAuditLogRequest

type Service

type Service interface {
	// 存储
	SaveAuditLog(context.Context, *AuditLog) error
	// 查询
	QueryAuditLog(context.Context, *QueryAuditLogRequest) (*types.Set[*AuditLog], error)
}

func GetService

func GetService() Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL