waf.go 1.26 KB
Newer Older
qiuqunfeng's avatar
qiuqunfeng committed
1 2 3 4
package api

import (
	"github.com/gin-gonic/gin"
5
	"github.com/olivere/elastic/v7"
qiuqunfeng's avatar
qiuqunfeng committed
6
	"gitlab.com/tensorsecurity-rd/waf-console/internal/controller"
qiuqunfeng's avatar
qiuqunfeng committed
7
	"gitlab.com/tensorsecurity-rd/waf-console/internal/utils"
qiuqunfeng's avatar
qiuqunfeng committed
8 9 10
	"gorm.io/gorm"
)

11
func SetWafRouter(e *gin.Engine, clusterClientManager *utils.ClusterClientManager, db *gorm.DB, gatewayUrl string, elasticClient *elastic.Client) {
qiuqunfeng's avatar
qiuqunfeng committed
12
	v1 := e.Group("v1/api/waf")
qiuqunfeng's avatar
qiuqunfeng committed
13

14
	wafController := controller.NewWafController(clusterClientManager, db, gatewayUrl, elasticClient)
qiuqunfeng's avatar
qiuqunfeng committed
15
	v1.GET("", wafController.Waf)
qiuqunfeng's avatar
qiuqunfeng committed
16
	v1.POST("/", wafController.CreateWaf)
qiuqunfeng's avatar
commit  
qiuqunfeng committed
17
	v1.PUT("mode", wafController.UpdateMode)
qiuqunfeng's avatar
qiuqunfeng committed
18 19 20
	v1.PUT("rules", wafController.UpdateRule)
	v1.PUT("listener/enable", wafController.EnableListenerWaf)
	v1.PUT("gateway/enable", wafController.EnableGatewayWaf)
21
	v1.POST("listeners/enable", wafController.EnableListenerWafs)
qiuqunfeng's avatar
qiuqunfeng committed
22 23
	v1.DELETE("listener/:region_code/:namespace/:gateway_name/:port", wafController.DeleteListenerWaf)
	v1.DELETE("gateway/:region_code/:namespace/:gateway_name", wafController.DeleteGatewayWaf)
qiuqunfeng's avatar
commit  
qiuqunfeng committed
24
	v1.POST("debug/savecatagory", wafController.SaveRuleCategoryToDB)
25 26 27 28 29

	v2 := e.Group("api/v2/containerSec/waf")
	v2.GET("/attack/log/list", wafController.ListAttackLogs)
	v2.GET("/rules", wafController.ListRules)
	v2.PUT("/rules", wafController.UpdateRule)
qiuqunfeng's avatar
qiuqunfeng committed
30
}