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

+1 -3
View File
@@ -12,7 +12,7 @@ export * from './modules/monitor';
export * from './modules/misc';
// Aggregate mockData object (cross-module references)
import { sqlAuditRecords, sqlAuditRules, resourceModels, modelInstances } from './modules/misc';
import { resourceModels, modelInstances } from './modules/misc';
import { ansiblePlaybooks, ansibleJobs, ansibleInventories, cronJobsList, cronJobExecutions, scripts } from './modules/automation';
import { logMonitorEntries, logSources, traces, serviceMetrics, traceSpans, grafanaDashboards, datasources } from './modules/monitor';
import { alertCenterAlerts, alertCenterRules, notificationChannels, recentAlerts, alertEvents } from './modules/alerts';
@@ -25,8 +25,6 @@ import { pendingApprovals, currentUser, users } from './modules/system';
import { tickets, approvalFlows, approvalInstances } from './modules/approval';
export const mockData = {
sqlAuditRecords,
sqlAuditRules,
resourceModels,
modelInstances,
ansiblePlaybooks,
-90
View File
@@ -132,96 +132,6 @@ export const modelInstances: ModelInstance[] = [
},
];
// ============ SQL审计数据 ============
export const sqlAuditRecords = [
{
id: 'audit-001',
sqlContent: 'UPDATE users SET status = "inactive" WHERE last_login < "2024-01-01"',
sqlType: 'UPDATE',
databaseName: 'production_db',
tableName: 'users',
riskLevel: 'medium',
riskRules: ['批量更新', '无WHERE条件限制'],
status: 'pending',
executor: '张工程师',
createdAt: '2025-04-14 10:30:00',
sourceIP: '192.168.1.100',
application: 'user-management-service'
},
{
id: 'audit-002',
sqlContent: 'DELETE FROM logs WHERE created_at < DATE_SUB(NOW(), INTERVAL 90 DAY)',
sqlType: 'DELETE',
databaseName: 'production_db',
tableName: 'logs',
riskLevel: 'high',
riskRules: ['批量删除', '影响大量数据'],
status: 'approved',
executor: '李运维',
approver: '王经理',
executeTime: '2025-04-14 09:00:00',
createdAt: '2025-04-14 08:30:00',
affectedRows: 500000,
executionTime: 12500,
sourceIP: '192.168.1.101',
application: 'log-cleanup-service'
},
{
id: 'audit-003',
sqlContent: 'SELECT * FROM orders WHERE user_id = 12345',
sqlType: 'SELECT',
databaseName: 'production_db',
tableName: 'orders',
riskLevel: 'safe',
riskRules: [],
status: 'executed',
executor: '王开发',
executeTime: '2025-04-14 10:15:00',
createdAt: '2025-04-14 10:15:00',
affectedRows: 0,
executionTime: 45,
sourceIP: '192.168.1.102',
application: 'order-service'
},
{
id: 'audit-004',
sqlContent: 'ALTER TABLE users ADD COLUMN phone_verified BOOLEAN DEFAULT FALSE',
sqlType: 'DDL',
databaseName: 'production_db',
tableName: 'users',
riskLevel: 'high',
riskRules: ['DDL操作', '表结构变更'],
status: 'pending',
executor: '张工程师',
createdAt: '2025-04-14 11:00:00',
sourceIP: '192.168.1.100',
application: 'db-migration-tool'
},
{
id: 'audit-005',
sqlContent: 'DROP TABLE temp_backup_2024',
sqlType: 'DDL',
databaseName: 'production_db',
tableName: 'temp_backup_2024',
riskLevel: 'high',
riskRules: ['删除表', '高危操作'],
status: 'rejected',
executor: '李运维',
createdAt: '2025-04-14 09:30:00',
sourceIP: '192.168.1.101',
application: 'cleanup-script'
}
];
export const sqlAuditRules = [
{ id: 'rule-001', name: '禁止无WHERE条件的UPDATE', description: '检测UPDATE语句是否包含WHERE条件', enabled: true, severity: 'high', category: 'DML' },
{ id: 'rule-002', name: '禁止无WHERE条件的DELETE', description: '检测DELETE语句是否包含WHERE条件', enabled: true, severity: 'high', category: 'DML' },
{ id: 'rule-003', name: '限制批量更新影响行数', description: 'UPDATE/DELETE影响行数超过1000条需要审批', enabled: true, severity: 'medium', category: 'DML' },
{ id: 'rule-004', name: 'DDL操作需要审批', description: 'ALTER、DROP等DDL操作需要高级审批', enabled: true, severity: 'high', category: 'DDL' },
{ id: 'rule-005', name: '禁止SELECT *', description: '建议明确指定查询字段', enabled: false, severity: 'low', category: 'DQL' },
{ id: 'rule-006', name: '敏感表操作审计', description: '对用户表、订单表等敏感表的操作进行审计', enabled: true, severity: 'medium', category: 'AUDIT' }
];
// ============ Ansible数据 ============
// mockData aggregate moved to data.ts barrel (references cross-module exports)