feat(audit): 审计日志保留期清理(后端自动清理 + 审计页配置)#83
Merged
Merged
Conversation
审计日志此前不限期增长。企业合规(数据生命周期管理)与存储治理需要可配置的 保留期 + 自动清理。 - AuditLogRepository.DeleteBefore:按 created_at 删除超期日志。 - AuditService.PurgeOlderThan + StartRetentionMonitor:每 6h 读取 audit_retention_days 设置并清理超期日志;0/缺省=永久保留(向后兼容,默认不删历史)。 - settings 新增 audit_retention_days 键(纳入 allow-list)。 - app.go 启动保留期后台监控。 - audit_retention_test 覆盖:DeleteBefore、PurgeOlderThan(<=0 不删/>0 删)、 设置驱动清理、0=永久保留。
审计日志页头新增管理员可见的「日志保留期」控件(天数输入,0=永久保留)+ 保存按钮, 写入 audit_retention_days 设置;后端每 6h 据此自动清理超期日志。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
审计日志此前不限期增长。企业合规(数据生命周期管理,SOC2/ISO27001/等保)与存储治理都需要可配置的保留期 + 自动清理。
后端
AuditLogRepository.DeleteBefore(cutoff):按created_at删除超期日志。AuditService.PurgeOlderThan(days)+StartRetentionMonitor:每 6h 读取audit_retention_days设置并清理超期日志;0/缺省 = 永久保留(向后兼容,默认不删任何历史)。audit_retention_days键(纳入显式 allow-list);app.go启动后台监控。前端
0= 永久)+ 保存按钮,写入设置后由后端自动执行清理。测试
audit_retention_test:DeleteBefore/PurgeOlderThan(≤0 不删、>0 删) / 设置驱动清理 /0=永久保留。补齐fakeAuditRepo的新接口方法。go test ./...全绿;前端tsc + vite build通过。