feat(backend): add script interpreters
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/grpcsrv/commander"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/handlers"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/repository"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/service"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/storage"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto/proto"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -86,6 +87,14 @@ func main() {
|
||||
|
||||
cmdr := commander.New(jobRepo)
|
||||
|
||||
// Initialize script interpreter repository and service
|
||||
scriptRepo := repository.NewScriptInterpreterRepo(db)
|
||||
if err := scriptRepo.Init(context.Background()); err != nil {
|
||||
log.Printf("Warning: failed to initialize script interpreters table: %v", err)
|
||||
}
|
||||
scriptSvc := service.NewScriptService(scriptRepo)
|
||||
scriptHandlers := handlers.NewScriptHandlers(scriptSvc, cmdr)
|
||||
|
||||
agents := handlers.NewAgentsGroup(h, coll)
|
||||
auth := handlers.AuthGroup{Handlers: h}
|
||||
agentReg := handlers.NewAgentRegistrationGroup(h)
|
||||
@@ -193,6 +202,18 @@ func main() {
|
||||
logsGroup.GET("/agents", logHandlers.GetAgents)
|
||||
logsGroup.GET("/levels", logHandlers.GetLevels)
|
||||
}
|
||||
|
||||
// Scripts (requires admin permission)
|
||||
scriptsGroup := v1.Group("/scripts")
|
||||
scriptsGroup.Use(auth.AuthMiddleware(), handlers.RequireAdmin())
|
||||
{
|
||||
scriptsGroup.POST("/run", scriptHandlers.RunScript)
|
||||
scriptsGroup.GET("/interpreters", scriptHandlers.ListInterpreters)
|
||||
scriptsGroup.POST("/interpreters", scriptHandlers.CreateInterpreter)
|
||||
scriptsGroup.GET("/interpreters/:id", scriptHandlers.GetInterpreter)
|
||||
scriptsGroup.PUT("/interpreters/:id", scriptHandlers.UpdateInterpreter)
|
||||
scriptsGroup.DELETE("/interpreters/:id", scriptHandlers.DeleteInterpreter)
|
||||
}
|
||||
}
|
||||
|
||||
// Start gRPC server with mTLS in background
|
||||
|
||||
Reference in New Issue
Block a user