Commit 2e7672eb authored by qiuqunfeng's avatar qiuqunfeng
Browse files

Add debug logging for WAF attack log retrieval

- Add log statements to track Elasticsearch query hits and source data
- Improve visibility into WAF attack log retrieval process
- Log raw Elasticsearch response and individual hit sources for debugging
parent 5d6557ae
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/olivere/elastic/v7" "github.com/olivere/elastic/v7"
"github.com/rs/zerolog/log"
"gitlab.com/tensorsecurity-rd/waf-console/internal/service" "gitlab.com/tensorsecurity-rd/waf-console/internal/service"
"gitlab.com/tensorsecurity-rd/waf-console/internal/utils" "gitlab.com/tensorsecurity-rd/waf-console/internal/utils"
"gorm.io/gorm" "gorm.io/gorm"
...@@ -299,6 +300,7 @@ func (c *WafController) ListAttackLogs(ctx *gin.Context) { ...@@ -299,6 +300,7 @@ func (c *WafController) ListAttackLogs(ctx *gin.Context) {
utils.AssembleResponse(ctx, nil, err) utils.AssembleResponse(ctx, nil, err)
return return
} }
log.Info().Interface("logs", logs).Msg("logs")
type resp struct { type resp struct {
Items []service.AttackLog `json:"items"` Items []service.AttackLog `json:"items"`
......
...@@ -827,7 +827,9 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) ( ...@@ -827,7 +827,9 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) (
list := make([]model.WafDetection, len(res.Hits.Hits)) list := make([]model.WafDetection, len(res.Hits.Hits))
endIdx := len(res.Hits.Hits) - 1 endIdx := len(res.Hits.Hits) - 1
pageToken := "" pageToken := ""
log.Info().Interface("hits", res.Hits.Hits).Msg("list attack logs res")
for i, hit := range res.Hits.Hits { for i, hit := range res.Hits.Hits {
log.Info().Interface("hit source", hit.Source).Msg("hit")
wafDetection := model.WafDetection{} wafDetection := model.WafDetection{}
if err = json.Unmarshal(hit.Source, &wafDetection); err != nil { if err = json.Unmarshal(hit.Source, &wafDetection); err != nil {
return nil, "", fmt.Errorf("failed to unmarshal waf detection: %v", err) return nil, "", fmt.Errorf("failed to unmarshal waf detection: %v", err)
......
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