refactor: Sanitize log inputs in chunk and session handlers to enhance security
This commit is contained in:
@@ -145,8 +145,6 @@ func (s *chunkService) ListPagedChunksByKnowledgeID(ctx context.Context,
|
|||||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||||
"knowledge_id": knowledgeID,
|
"knowledge_id": knowledgeID,
|
||||||
"tenant_id": tenantID,
|
"tenant_id": tenantID,
|
||||||
"page": page.Page,
|
|
||||||
"page_size": page.PageSize,
|
|
||||||
})
|
})
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -211,12 +209,7 @@ func (s *chunkService) UpdateChunks(ctx context.Context, chunks []*types.Chunk)
|
|||||||
// Returns:
|
// Returns:
|
||||||
// - error: Any error encountered during deletion
|
// - error: Any error encountered during deletion
|
||||||
func (s *chunkService) DeleteChunk(ctx context.Context, id string) error {
|
func (s *chunkService) DeleteChunk(ctx context.Context, id string) error {
|
||||||
logger.Info(ctx, "Start deleting chunk")
|
|
||||||
logger.Infof(ctx, "Deleting chunk, ID: %s", id)
|
|
||||||
|
|
||||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||||
logger.Infof(ctx, "Tenant ID: %d", tenantID)
|
|
||||||
|
|
||||||
err := s.chunkRepository.DeleteChunk(ctx, tenantID, id)
|
err := s.chunkRepository.DeleteChunk(ctx, tenantID, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||||
@@ -225,7 +218,6 @@ func (s *chunkService) DeleteChunk(ctx context.Context, id string) error {
|
|||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info(ctx, "Chunk deleted successfully")
|
logger.Info(ctx, "Chunk deleted successfully")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ func (h *Handler) KnowledgeQA(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use shared function to handle KnowledgeQA request
|
// Use shared function to handle KnowledgeQA request
|
||||||
h.handleKnowledgeQARequest(ctx, c, session, request.Query, knowledgeBaseIDs, assistantMessage, true, request.SummaryModelID, request.WebSearchEnabled)
|
h.handleKnowledgeQARequest(ctx, c, session, secutils.SanitizeForLog(request.Query),
|
||||||
|
knowledgeBaseIDs, assistantMessage, true, secutils.SanitizeForLog(request.SummaryModelID), request.WebSearchEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AgentQA handles agent-based question answering with conversation history and streaming
|
// AgentQA handles agent-based question answering with conversation history and streaming
|
||||||
|
|||||||
Reference in New Issue
Block a user