mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-08-08 20:06:07 +02:00
Add files via upload
This commit is contained in:
+37
-20
@@ -10,8 +10,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"cyberstrike-ai/internal/audit"
|
"cyberstrike-ai/internal/audit"
|
||||||
|
"cyberstrike-ai/internal/config"
|
||||||
"cyberstrike-ai/internal/database"
|
"cyberstrike-ai/internal/database"
|
||||||
"cyberstrike-ai/internal/mcp"
|
"cyberstrike-ai/internal/mcp"
|
||||||
|
"cyberstrike-ai/internal/monitor"
|
||||||
"cyberstrike-ai/internal/security"
|
"cyberstrike-ai/internal/security"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@@ -19,12 +21,18 @@ import (
|
|||||||
|
|
||||||
// MonitorHandler 监控处理器
|
// MonitorHandler 监控处理器
|
||||||
type MonitorHandler struct {
|
type MonitorHandler struct {
|
||||||
mcpServer *mcp.Server
|
mcpServer *mcp.Server
|
||||||
externalMCPMgr *mcp.ExternalMCPManager
|
externalMCPMgr *mcp.ExternalMCPManager
|
||||||
executor *security.Executor
|
executor *security.Executor
|
||||||
db *database.DB
|
db *database.DB
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
audit *audit.Service
|
audit *audit.Service
|
||||||
|
monitorRetention *monitor.Service
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMonitorRetention wires MCP execution retention settings.
|
||||||
|
func (h *MonitorHandler) SetMonitorRetention(s *monitor.Service) {
|
||||||
|
h.monitorRetention = s
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAudit wires platform audit logging.
|
// SetAudit wires platform audit logging.
|
||||||
@@ -50,13 +58,14 @@ func (h *MonitorHandler) SetExternalMCPManager(mgr *mcp.ExternalMCPManager) {
|
|||||||
|
|
||||||
// MonitorResponse 监控响应
|
// MonitorResponse 监控响应
|
||||||
type MonitorResponse struct {
|
type MonitorResponse struct {
|
||||||
Executions []*mcp.ToolExecution `json:"executions"`
|
Executions []*mcp.ToolExecution `json:"executions"`
|
||||||
Stats map[string]*mcp.ToolStats `json:"stats"`
|
Stats map[string]*mcp.ToolStats `json:"stats"`
|
||||||
Timestamp time.Time `json:"timestamp"`
|
Timestamp time.Time `json:"timestamp"`
|
||||||
Total int `json:"total,omitempty"`
|
Total int `json:"total,omitempty"`
|
||||||
Page int `json:"page,omitempty"`
|
Page int `json:"page,omitempty"`
|
||||||
PageSize int `json:"page_size,omitempty"`
|
PageSize int `json:"page_size,omitempty"`
|
||||||
TotalPages int `json:"total_pages,omitempty"`
|
TotalPages int `json:"total_pages,omitempty"`
|
||||||
|
RetentionDays int `json:"retention_days,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monitor 获取监控信息
|
// Monitor 获取监控信息
|
||||||
@@ -89,16 +98,24 @@ func (h *MonitorHandler) Monitor(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, MonitorResponse{
|
c.JSON(http.StatusOK, MonitorResponse{
|
||||||
Executions: executions,
|
Executions: executions,
|
||||||
Stats: stats,
|
Stats: stats,
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: page,
|
Page: page,
|
||||||
PageSize: pageSize,
|
PageSize: pageSize,
|
||||||
TotalPages: totalPages,
|
TotalPages: totalPages,
|
||||||
|
RetentionDays: h.monitorRetentionDays(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *MonitorHandler) monitorRetentionDays() int {
|
||||||
|
if h.monitorRetention != nil {
|
||||||
|
return h.monitorRetention.RetentionDays()
|
||||||
|
}
|
||||||
|
return config.MonitorConfig{}.RetentionDaysEffective()
|
||||||
|
}
|
||||||
|
|
||||||
func (h *MonitorHandler) loadExecutions() []*mcp.ToolExecution {
|
func (h *MonitorHandler) loadExecutions() []*mcp.ToolExecution {
|
||||||
executions, _ := h.loadExecutionsWithPagination(1, 1000, "", "")
|
executions, _ := h.loadExecutionsWithPagination(1, 1000, "", "")
|
||||||
return executions
|
return executions
|
||||||
|
|||||||
Reference in New Issue
Block a user