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