Commit 6ad35326 authored by qiuqunfeng's avatar qiuqunfeng
Browse files
parents 3989b6ea f17ae858
...@@ -506,6 +506,7 @@ func (c *WafController) ListListenerHistory(ctx *gin.Context) { ...@@ -506,6 +506,7 @@ func (c *WafController) ListListenerHistory(ctx *gin.Context) {
utils.AssembleResponse(ctx, nil, err) utils.AssembleResponse(ctx, nil, err)
return return
} }
limit = 1000000
name := ctx.Query("name") name := ctx.Query("name")
gatewayName := ctx.Query("gateway_name") gatewayName := ctx.Query("gateway_name")
listenerName := ctx.Query("listener_name") listenerName := ctx.Query("listener_name")
......
...@@ -164,17 +164,9 @@ func (s *LogConsumerService) Handle(ctx context.Context, message []byte) error { ...@@ -164,17 +164,9 @@ func (s *LogConsumerService) Handle(ctx context.Context, message []byte) error {
s.esStore.Save(ctx, bulkableRequests) s.esStore.Save(ctx, bulkableRequests)
wafService := model.WafService{} err = s.db.WithContext(ctx).Model(&model.WafService{}).Where("id = ?", WafDetectionMessage.ServiceID).Update("attack_num", gorm.Expr("attack_num + ?", 1)).Error
err = s.db.WithContext(ctx).Where("id = ?", WafDetectionMessage.ServiceID).First(&wafService).Error
if err != nil { if err != nil {
log.Err(err).Int64("WafDetectionMessage.ServiceID", WafDetectionMessage.ServiceID).Msg("Find waf_service fails") log.Err(err).Int64("WafDetectionMessage.ServiceID", WafDetectionMessage.ServiceID).Msg("update waf_service attack_number fails")
return err
}
attackNumber := int(wafService.AttackNum) + unPassCount
err = s.db.WithContext(ctx).Model(&model.WafService{}).Where("id = ?", WafDetectionMessage.ServiceID).Update("attack_number", attackNumber).Error
if err != nil {
log.Err(err).Int64("WafDetectionMessage.ServiceID", WafDetectionMessage.ServiceID).Int("attack_number", attackNumber).Msg("update waf_service attack_number fails")
return err return err
} }
......
...@@ -349,7 +349,7 @@ type AttackLogFilter struct { ...@@ -349,7 +349,7 @@ type AttackLogFilter struct {
AttackUrl string `json:"attack_url"` AttackUrl string `json:"attack_url"`
AttackIp string `json:"attack_ip"` AttackIp string `json:"attack_ip"`
AttackType string `json:"attack_type"` AttackType string `json:"attack_type"`
AttackApp string `json:"attack_app"` AttackApp string `json:"attack_app"` // gateway name
AttackListener string `json:"attack_listener"` AttackListener string `json:"attack_listener"`
Action string `json:"action"` Action string `json:"action"`
Token string `json:"token"` Token string `json:"token"`
......
...@@ -250,7 +250,7 @@ func (s *wafService) CreateWaf(ctx context.Context, req *CreateWafReq) (*WafServ ...@@ -250,7 +250,7 @@ func (s *wafService) CreateWaf(ctx context.Context, req *CreateWafReq) (*WafServ
Port: req.Port, Port: req.Port,
Workload: v1alpha1.WorkloadRef{ Workload: v1alpha1.WorkloadRef{
Kind: req.GatewayName, Kind: req.GatewayName,
Name: req.ListenerName, Name: req.GatewayName,
Namespace: req.Namespace, Namespace: req.Namespace,
ClusterKey: req.RegionCode, ClusterKey: req.RegionCode,
}, },
...@@ -841,7 +841,7 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) ( ...@@ -841,7 +841,7 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) (
boolQuery.Filter(elastic.NewMatchPhraseQuery("attack_ip", req.AttackIp).Slop(0)) boolQuery.Filter(elastic.NewMatchPhraseQuery("attack_ip", req.AttackIp).Slop(0))
} }
if req.AttackApp != "" { if req.AttackApp != "" {
boolQuery.Filter(elastic.NewMatchPhraseQuery("attacked_app", req.AttackApp).Slop(0)) boolQuery.Filter(elastic.NewMatchPhraseQuery("res_name", req.AttackApp).Slop(0))
} }
if req.AttackType != "" { if req.AttackType != "" {
attackTypes := strings.Split(req.AttackType, ",") attackTypes := strings.Split(req.AttackType, ",")
...@@ -921,8 +921,7 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) ( ...@@ -921,8 +921,7 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) (
Uuid: wafDetection.ID, Uuid: wafDetection.ID,
AttackTime: wafDetection.AttackTime, AttackTime: wafDetection.AttackTime,
AttackIp: wafDetection.AttackIP, AttackIp: wafDetection.AttackIP,
AttackedApp: wafDetection.AttackedApp, AttackListener: wafDetection.AttackedApp,
AttackListener: wafDetection.ResName,
AttackType: wafDetection.AttackType, AttackType: wafDetection.AttackType,
Action: wafDetection.Action, Action: wafDetection.Action,
ClusterKey: wafDetection.ClusterKey, ClusterKey: wafDetection.ClusterKey,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment