This commit is contained in:
@@ -40,104 +40,104 @@ type EventFilter struct {
|
||||
|
||||
// EventPage 是平台全局事件稳定分页结果。
|
||||
type EventPage struct {
|
||||
Total int64 `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
Items []EventView `json:"items"`
|
||||
Retention retentionquery.Info `json:"retention"`
|
||||
Total int64 `json:"total" description:"符合条件的事件总数"`
|
||||
Page int `json:"page" description:"当前页码"`
|
||||
PageSize int `json:"page_size" description:"每页数量"`
|
||||
Items []EventView `json:"items" description:"审计事件列表,按发生时间和主键稳定倒序"`
|
||||
Retention retentionquery.Info `json:"retention" description:"在线查询留存边界"`
|
||||
}
|
||||
|
||||
// EventDetail 是单个审计事件及在线留存边界。
|
||||
type EventDetail struct {
|
||||
EventView
|
||||
Retention retentionquery.Info `json:"retention"`
|
||||
Retention retentionquery.Info `json:"retention" description:"在线查询留存边界"`
|
||||
}
|
||||
|
||||
// EventView 是不暴露 GORM Model 的审计事件投影。
|
||||
type EventView struct {
|
||||
EventID string `json:"event_id"`
|
||||
OccurredAt time.Time `json:"occurred_at"`
|
||||
Category string `json:"category"`
|
||||
ActionCode string `json:"action_code"`
|
||||
ActionName string `json:"action_name"`
|
||||
Summary string `json:"summary"`
|
||||
ActorKind string `json:"actor_kind"`
|
||||
ActorID string `json:"actor_id"`
|
||||
ActorName string `json:"actor_name"`
|
||||
ActorShopID *uint `json:"actor_shop_id,omitempty"`
|
||||
ActorShopName string `json:"actor_shop_name"`
|
||||
ActorEnterpriseID *uint `json:"actor_enterprise_id,omitempty"`
|
||||
ActorEnterpriseName string `json:"actor_enterprise_name"`
|
||||
Source string `json:"source"`
|
||||
RequestPath string `json:"request_path"`
|
||||
RequestMethod string `json:"request_method"`
|
||||
IPAddress string `json:"ip_address"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
ScopeType string `json:"scope_type"`
|
||||
ScopeID string `json:"scope_id"`
|
||||
ScopeName string `json:"scope_name"`
|
||||
Result string `json:"result"`
|
||||
RiskLevel string `json:"risk_level"`
|
||||
ErrorCode string `json:"error_code"`
|
||||
ErrorSummary string `json:"error_summary"`
|
||||
RequestID string `json:"request_id"`
|
||||
CorrelationID string `json:"correlation_id"`
|
||||
ParentEventID string `json:"parent_event_id"`
|
||||
BatchTotal int `json:"batch_total"`
|
||||
SuccessCount int `json:"success_count"`
|
||||
FailCount int `json:"fail_count"`
|
||||
Metadata map[string]any `json:"metadata"`
|
||||
ContentHash string `json:"content_hash"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Resources []ResourceView `json:"resources"`
|
||||
InvestigationRefs InvestigationRefs `json:"investigation_refs"`
|
||||
EventID string `json:"event_id" description:"稳定审计事件ID,可传给事件详情接口"`
|
||||
OccurredAt time.Time `json:"occurred_at" description:"业务事实发生时间"`
|
||||
Category string `json:"category" enum:"configuration,reliability,asset,security,identity,business" description:"动作类别稳定编码"`
|
||||
ActionCode string `json:"action_code" description:"稳定动作编码;筛选和跳转必须使用该值"`
|
||||
ActionName string `json:"action_name" description:"action_code对应的中文展示名称"`
|
||||
Summary string `json:"summary" description:"事件中文摘要"`
|
||||
ActorKind string `json:"actor_kind" enum:"account,personal_customer,openapi,system_task,scheduled_job,external_system" description:"操作者类型稳定编码"`
|
||||
ActorID string `json:"actor_id" description:"操作者稳定ID,与actor_kind共同定位操作者时间线"`
|
||||
ActorName string `json:"actor_name" description:"事件发生时的操作者名称快照"`
|
||||
ActorShopID *uint `json:"actor_shop_id,omitempty" description:"操作者所属店铺ID快照"`
|
||||
ActorShopName string `json:"actor_shop_name" description:"操作者所属店铺名称快照"`
|
||||
ActorEnterpriseID *uint `json:"actor_enterprise_id,omitempty" description:"操作者所属企业ID快照"`
|
||||
ActorEnterpriseName string `json:"actor_enterprise_name" description:"操作者所属企业名称快照"`
|
||||
Source string `json:"source" enum:"admin_api,personal_api,openapi,worker,scheduler,callback" description:"操作入口来源稳定编码"`
|
||||
RequestPath string `json:"request_path" description:"触发操作的HTTP路径;非HTTP入口可为空"`
|
||||
RequestMethod string `json:"request_method" description:"触发操作的HTTP方法;非HTTP入口可为空"`
|
||||
IPAddress string `json:"ip_address" description:"触发请求的IP地址;非HTTP入口可为空"`
|
||||
UserAgent string `json:"user_agent" description:"触发请求的User-Agent;非HTTP入口可为空"`
|
||||
ScopeType string `json:"scope_type" enum:"platform,shop,personal_customer" description:"业务范围类型稳定编码"`
|
||||
ScopeID string `json:"scope_id" description:"业务范围稳定ID,与scope_type共同使用"`
|
||||
ScopeName string `json:"scope_name" description:"业务范围名称快照"`
|
||||
Result string `json:"result" enum:"success,failed,denied,partial,unknown" description:"事件结果稳定编码"`
|
||||
RiskLevel string `json:"risk_level" enum:"low,normal,high,critical" description:"风险等级稳定编码"`
|
||||
ErrorCode string `json:"error_code" description:"失败或拒绝时的稳定错误码"`
|
||||
ErrorSummary string `json:"error_summary" description:"已脱敏的失败原因摘要"`
|
||||
RequestID string `json:"request_id" description:"HTTP请求关联ID,可传给请求时间线接口"`
|
||||
CorrelationID string `json:"correlation_id" description:"跨请求业务链路ID,可传给关联时间线接口"`
|
||||
ParentEventID string `json:"parent_event_id" description:"批量或异步链路的父审计事件ID"`
|
||||
BatchTotal int `json:"batch_total" description:"批次声明处理总数,非批次为0"`
|
||||
SuccessCount int `json:"success_count" description:"批次成功数,非批次为0"`
|
||||
FailCount int `json:"fail_count" description:"批次失败数,非批次为0"`
|
||||
Metadata map[string]any `json:"metadata" description:"已脱敏的动作扩展元数据,字段由action_code定义"`
|
||||
ContentHash string `json:"content_hash" description:"事件不可变内容摘要"`
|
||||
CreatedAt time.Time `json:"created_at" description:"审计记录写入时间"`
|
||||
Resources []ResourceView `json:"resources" description:"事件涉及的全部资源及各自前后快照"`
|
||||
InvestigationRefs InvestigationRefs `json:"investigation_refs" description:"跨审计视角的稳定跳转参数集合"`
|
||||
}
|
||||
|
||||
// InvestigationRefs 是平台调查视角间唯一允许使用的稳定跳转引用。
|
||||
type InvestigationRefs struct {
|
||||
EventID *string `json:"event_id"`
|
||||
ActorRef *ActorRef `json:"actor_ref"`
|
||||
ResourceRefs []InvestigationResourceRef `json:"resource_refs"`
|
||||
RequestID *string `json:"request_id"`
|
||||
CorrelationID *string `json:"correlation_id"`
|
||||
IntegrationRefs []IntegrationRef `json:"integration_refs"`
|
||||
EventID *string `json:"event_id" description:"传给GET /audit/events/{event_id}"`
|
||||
ActorRef *ActorRef `json:"actor_ref" description:"kind/id传给GET /audit/actors/{kind}/{id}/events"`
|
||||
ResourceRefs []InvestigationResourceRef `json:"resource_refs" description:"resource_type/resource_id传给GET /audit/resources/{resource_type}/{resource_id}/timeline;resource_id为空时不可跳转"`
|
||||
RequestID *string `json:"request_id" description:"传给GET /audit/requests/{request_id}/timeline"`
|
||||
CorrelationID *string `json:"correlation_id" description:"传给GET /audit/correlations/{correlation_id}/timeline"`
|
||||
IntegrationRefs []IntegrationRef `json:"integration_refs" description:"integration_id传给GET /audit/integrations/{integration_id}"`
|
||||
}
|
||||
|
||||
// ActorRef 是操作者时间线的稳定引用。
|
||||
type ActorRef struct {
|
||||
Kind string `json:"kind"`
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind" enum:"account,personal_customer,openapi,system_task,scheduled_job,external_system" description:"操作者类型"`
|
||||
ID string `json:"id" description:"操作者稳定ID"`
|
||||
}
|
||||
|
||||
// InvestigationResourceRef 是通用资源时间线的稳定引用。
|
||||
type InvestigationResourceRef struct {
|
||||
ResourceType string `json:"resource_type"`
|
||||
ResourceID *string `json:"resource_id"`
|
||||
ResourceKey string `json:"resource_key"`
|
||||
DisplayName string `json:"display_name"`
|
||||
ResourceType string `json:"resource_type" description:"Resource Registry注册类型"`
|
||||
ResourceID *string `json:"resource_id" description:"资源内部稳定ID;为空时不展示平台资源时间线入口"`
|
||||
ResourceKey string `json:"resource_key" description:"资源业务稳定Key,用于展示或精确搜索"`
|
||||
DisplayName string `json:"display_name" description:"事件发生时的资源展示名称"`
|
||||
}
|
||||
|
||||
// IntegrationRef 是 Integration 详情的稳定引用。
|
||||
type IntegrationRef struct {
|
||||
IntegrationID string `json:"integration_id"`
|
||||
IntegrationID string `json:"integration_id" description:"稳定外部集成记录ID"`
|
||||
}
|
||||
|
||||
// ResourceView 是事件发生时独立资源身份与变化的只读投影。
|
||||
type ResourceView struct {
|
||||
ResourceType string `json:"resource_type"`
|
||||
ResourceID *string `json:"resource_id,omitempty"`
|
||||
ResourceKey string `json:"resource_key"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Relation string `json:"relation"`
|
||||
Role string `json:"role"`
|
||||
IdentitySnapshot map[string]any `json:"identity_snapshot"`
|
||||
BeforeData map[string]any `json:"before_data"`
|
||||
AfterData map[string]any `json:"after_data"`
|
||||
SubjectVisibility string `json:"subject_visibility"`
|
||||
SubjectSummary string `json:"subject_summary"`
|
||||
SubjectData map[string]any `json:"subject_data"`
|
||||
SortOrder int `json:"sort_order"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ResourceType string `json:"resource_type" description:"Resource Registry注册类型"`
|
||||
ResourceID *string `json:"resource_id,omitempty" description:"资源内部稳定ID"`
|
||||
ResourceKey string `json:"resource_key" description:"资源业务稳定Key"`
|
||||
DisplayName string `json:"display_name" description:"事件发生时的资源展示名称"`
|
||||
Relation string `json:"relation" enum:"primary,affected,reference" description:"资源关系 (primary:主要资源, affected:受影响资源, reference:引用资源)"`
|
||||
Role string `json:"role" description:"Resource Registry定义的资源业务角色编码"`
|
||||
IdentitySnapshot map[string]any `json:"identity_snapshot" description:"事件发生时的资源身份快照"`
|
||||
BeforeData map[string]any `json:"before_data" description:"该资源变更前的完整平台审计数据"`
|
||||
AfterData map[string]any `json:"after_data" description:"该资源变更后的完整平台审计数据"`
|
||||
SubjectVisibility string `json:"subject_visibility" enum:"internal_only,subject_result,subject_detail" description:"主体可见性 (internal_only:仅平台, subject_result:主体可见结论, subject_detail:主体可见安全详情)"`
|
||||
SubjectSummary string `json:"subject_summary" description:"允许代理或企业查看的安全摘要"`
|
||||
SubjectData map[string]any `json:"subject_data" description:"写入时生成的主体安全字段,不等同于before_data或after_data"`
|
||||
SortOrder int `json:"sort_order" description:"资源在事件内的稳定展示顺序"`
|
||||
CreatedAt time.Time `json:"created_at" description:"资源关联记录写入时间"`
|
||||
}
|
||||
|
||||
// Query 提供平台统一审计事件列表与详情读取。
|
||||
|
||||
Reference in New Issue
Block a user