refactor: 清理SQL审计全栈死代码 (删除孤立组件+handler+model+路由+mock+API定义, 共-1278行)

SQL审计菜单此前已从侧边栏移除,但死代码残留(违反step5清理清单):
- 删除 frontend/components/audit/SQLAuditManager.tsx (629行, 无任何外部引用)
- 删除 backend/handlers/sql_audit.go (435行) + backend/models/sql_audit.go (64行)
- 移除 routes.go 中13条SQL审计路由 (API不再暴露, 返回404)
- 移除 database.go AutoMigrate 中2个SQL审计表
- 移除 api.ts sqlAuditApi 对象 (37行)
- 移除 mocks SQL审计mock数据 (90行) + barrel引用
This commit is contained in:
attacker committed 2026-06-16 03:05:14 +08:00
1 parent a6e8b5ab4f
commit a26f186e9b
8 files changed
+1 -1278

No files matched your search

-64
View File
@@ -1,64 +0,0 @@
package models
import (
"time"
"gorm.io/gorm"
)
// SQLAuditRecord SQL审计记录 // Logan.Li
type SQLAuditRecord struct {
ID uint `gorm:"primarykey" json:"id"`
SQLContent string `gorm:"type:text;not null" json:"sql_content"`
SQLType string `gorm:"size:50" json:"sql_type"` // DDL/DML/DQL/DCL
DatabaseName string `gorm:"size:255" json:"database_name"`
TargetTable string `gorm:"column:table_name;size:255" json:"table_name"`
RiskLevel string `gorm:"size:20;default:safe" json:"risk_level"` // high/medium/low/safe
RiskRules string `gorm:"type:text" json:"risk_rules"` // JSON 数组
Status string `gorm:"size:20;default:pending" json:"status"` // pending/approved/rejected/executed
Executor string `gorm:"size:255" json:"executor"`
Approver string `gorm:"size:255" json:"approver"`
ExecuteTime *time.Time `json:"execute_time"`
AffectedRows int64 `gorm:"default:0" json:"affected_rows"`
ExecutionTime int64 `gorm:"default:0" json:"execution_time"` // 毫秒
SourceIP string `gorm:"size:100" json:"source_ip"`
Application string `gorm:"size:255" json:"application"`
TicketID string `gorm:"size:100" json:"ticket_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (SQLAuditRecord) TableName() string { return "sql_audit_records" }
// SQLAuditRule SQL审计规则 // Logan.Li
type SQLAuditRule struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
Pattern string `gorm:"type:text" json:"pattern"` // 正则/关键词匹配
Enabled bool `gorm:"default:true" json:"enabled"`
Severity string `gorm:"size:20;default:medium" json:"severity"` // high/medium/low
Category string `gorm:"size:100" json:"category"` // DDL/DML/DROP/TRUNCATE/etc
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (SQLAuditRule) TableName() string { return "sql_audit_rules" }
// AnalyzeSQLRequest SQL分析请求 // Logan.Li
type AnalyzeSQLRequest struct {
SQL string `json:"sql"`
DatabaseName string `json:"database_name"`
Application string `json:"application"`
}
// AnalyzeSQLResponse SQL分析响应 // Logan.Li
type AnalyzeSQLResponse struct {
ID int64 `json:"id"`
RiskLevel string `json:"risk_level"`
RiskRules []string `json:"risk_rules"`
SQLType string `json:"sql_type"`
TableName string `json:"table_name"`
}