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 (
"github.com/gin-gonic/gin"
"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/utils"
"gorm.io/gorm"
......@@ -299,6 +300,7 @@ func (c *WafController) ListAttackLogs(ctx *gin.Context) {
utils.AssembleResponse(ctx, nil, err)
return
}
log.Info().Interface("logs", logs).Msg("logs")
type resp struct {
Items []service.AttackLog `json:"items"`
......
......@@ -827,7 +827,9 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) (
list := make([]model.WafDetection, len(res.Hits.Hits))
endIdx := len(res.Hits.Hits) - 1
pageToken := ""
log.Info().Interface("hits", res.Hits.Hits).Msg("list attack logs res")
for i, hit := range res.Hits.Hits {
log.Info().Interface("hit source", hit.Source).Msg("hit")
wafDetection := model.WafDetection{}
if err = json.Unmarshal(hit.Source, &wafDetection); err != nil {
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