feat: 完善日志审计功能
- 实现文件系统日志(FilesystemLog)记录文件管理器操作 - 实现操作日志(OperationLog)记录用户操作行为 - 实现数据库SQL日志(DatabaseSQLLog)模型和API - 实现SSH会话命令记录(SessionCommand)含命令输出和风险等级 - 添加IP提取服务支持X-Real-IP和X-Forwarded-For - 添加日志自动清理功能 - 修复ProFormSwitch required验证问题 - 修复设置页面默认值问题 - 修复文件上传错误检测逻辑 - 修复资产树key前缀问题 - 添加VNC/RDP设置默认值 - 修复文件管理标题翻译
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package model
|
||||
|
||||
import "next-terminal/server/common"
|
||||
|
||||
type AccessLog struct {
|
||||
ID string `gorm:"primary_key,type:varchar(36)" json:"id"`
|
||||
Domain string `gorm:"type:varchar(500);index" json:"domain"`
|
||||
WebsiteId string `gorm:"type:varchar(36);index" json:"websiteId"`
|
||||
AccountId string `gorm:"type:varchar(36);index" json:"accountId"`
|
||||
Method string `gorm:"type:varchar(10)" json:"method"`
|
||||
Uri string `gorm:"type:varchar(2000)" json:"uri"`
|
||||
StatusCode int `json:"statusCode"`
|
||||
ResponseSize int64 `json:"responseSize"`
|
||||
ClientIp string `gorm:"type:varchar(50);index" json:"clientIp"`
|
||||
Region string `gorm:"type:varchar(100)" json:"region"`
|
||||
UserAgent string `gorm:"type:varchar(500)" json:"userAgent"`
|
||||
Referer string `gorm:"type:varchar(2000)" json:"referer"`
|
||||
RequestTime int `json:"requestTime"`
|
||||
ResponseTime int `json:"responseTime"`
|
||||
Created common.JsonTime `gorm:"type:datetime;index" json:"createdAt"`
|
||||
}
|
||||
|
||||
func (r *AccessLog) TableName() string {
|
||||
return "access_logs"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/server/common"
|
||||
)
|
||||
|
||||
type DatabaseSQLLog struct {
|
||||
ID string `gorm:"primary_key,type:varchar(36)" json:"id"`
|
||||
AssetId string `gorm:"index,type:varchar(36)" json:"assetId"`
|
||||
Database string `gorm:"type:varchar(200)" json:"database"`
|
||||
UserId string `gorm:"index,type:varchar(36)" json:"userId"`
|
||||
ClientIP string `gorm:"type:varchar(50);index" json:"clientIp"`
|
||||
SQL string `gorm:"type:text" json:"sql"`
|
||||
DurationMs int `json:"durationMs"`
|
||||
RowsAffected int `json:"rowsAffected"`
|
||||
Status string `gorm:"type:varchar(20);index" json:"status"`
|
||||
ErrorMessage string `gorm:"type:text" json:"errorMessage"`
|
||||
Source string `gorm:"type:varchar(50);index" json:"source"`
|
||||
Created common.JsonTime `gorm:"type:datetime;index" json:"createdAt"`
|
||||
}
|
||||
|
||||
func (r *DatabaseSQLLog) TableName() string {
|
||||
return "database_sql_logs"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/server/common"
|
||||
)
|
||||
|
||||
type FilesystemLog struct {
|
||||
ID string `gorm:"primary_key,type:varchar(36)" json:"id"`
|
||||
AssetId string `gorm:"index,type:varchar(36)" json:"assetId"`
|
||||
SessionId string `gorm:"index,type:varchar(36)" json:"sessionId"`
|
||||
UserId string `gorm:"index,type:varchar(36)" json:"userId"`
|
||||
Action string `gorm:"type:varchar(50);index" json:"action"`
|
||||
FileName string `gorm:"type:varchar(500)" json:"fileName"`
|
||||
Created common.JsonTime `gorm:"type:datetime;index" json:"createdAt"`
|
||||
}
|
||||
|
||||
func (r *FilesystemLog) TableName() string {
|
||||
return "filesystem_logs"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/server/common"
|
||||
)
|
||||
|
||||
type OperationLog struct {
|
||||
ID string `gorm:"primary_key,type:varchar(36)" json:"id"`
|
||||
AccountId string `gorm:"index,type:varchar(36)" json:"accountId"`
|
||||
AccountName string `gorm:"type:varchar(200)" json:"accountName"`
|
||||
Action string `gorm:"type:varchar(100);index" json:"action"`
|
||||
Content string `gorm:"type:text" json:"content"`
|
||||
IP string `gorm:"type:varchar(50);index" json:"ip"`
|
||||
Region string `gorm:"type:varchar(200)" json:"region"`
|
||||
UserAgent string `gorm:"type:varchar(500)" json:"userAgent"`
|
||||
Status string `gorm:"type:varchar(20);index" json:"status"`
|
||||
ErrorMessage string `gorm:"type:text" json:"errorMessage"`
|
||||
Remark string `gorm:"type:varchar(500)" json:"remark"`
|
||||
Created common.JsonTime `gorm:"type:datetime;index" json:"createdAt"`
|
||||
}
|
||||
|
||||
func (r *OperationLog) TableName() string {
|
||||
return "operation_logs"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"next-terminal/server/common"
|
||||
)
|
||||
|
||||
type SessionCommand struct {
|
||||
ID string `gorm:"primary_key,type:varchar(36)" json:"id"`
|
||||
SessionId string `gorm:"index,type:varchar(36)" json:"sessionId"`
|
||||
RiskLevel int `json:"riskLevel"`
|
||||
Command string `gorm:"type:text" json:"command"`
|
||||
Output string `gorm:"type:text" json:"output"`
|
||||
Created common.JsonTime `gorm:"type:datetime;index" json:"createdAt"`
|
||||
}
|
||||
|
||||
func (r *SessionCommand) TableName() string {
|
||||
return "session_commands"
|
||||
}
|
||||
Reference in New Issue
Block a user