waf.go 1.65 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)
16
	v1.GET("list", wafController.ListWafs)
qiuqunfeng's avatar
qiuqunfeng committed
17
	v1.POST("/", wafController.CreateWaf)
qiuqunfeng's avatar
commit  
qiuqunfeng committed
18
	v1.PUT("mode", wafController.UpdateMode)
qiuqunfeng's avatar
qiuqunfeng committed
19 20 21
	v1.PUT("rules", wafController.UpdateRule)
	v1.PUT("listener/enable", wafController.EnableListenerWaf)
	v1.PUT("gateway/enable", wafController.EnableGatewayWaf)
22
	v1.POST("listeners/enable", wafController.EnableListenerWafs)
qiuqunfeng's avatar
qiuqunfeng committed
23 24
	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
25
	v1.POST("debug/savecatagory", wafController.SaveRuleCategoryToDB)
26 27

	v2 := e.Group("api/v2/containerSec/waf")
28 29 30
	v2.GET("attack/log/list", wafController.ListAttackLogs)
	v2.GET("rules", wafController.ListRules)
	v2.PUT("rules", wafController.UpdateRule)
31 32 33
	v2.POST("blackwhitelist", wafController.CreateBlackWhiteList)
	v2.PUT("blackwhitelist", wafController.UpdateBlackWhiteList)
	v2.PUT("blackwhitelist/enabling", wafController.EnableBlackWhiteList)
qiuqunfeng's avatar
debug  
qiuqunfeng committed
34
	v2.DELETE("blackwhitelist/:id", wafController.DeleteBlackWhiteList)
35
	v2.GET("blackwhitelists", wafController.GetBlackWhiteLists)
36
	v2.GET("services", wafController.ListWafs)
qiuqunfeng's avatar
qiuqunfeng committed
37
}