chore: replace pseudo-random generators with secrets module (#20616)

This commit is contained in:
Bowen Liang 2025-06-06 10:48:28 +08:00 • committed by GitHub
commit c1a13fa553
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 17 additions and 16 deletions

View file

@ -2,7 +2,7 @@ import copy
import datetime
import json
import logging
import random
import secrets
import time
import uuid
from collections import Counter
@ -970,7 +970,7 @@ class DocumentService:
documents.append(document)
batch = document.batch
else:
batch = time.strftime("%Y%m%d%H%M%S") + str(random.randint(100000, 999999))
batch = time.strftime("%Y%m%d%H%M%S") + str(100000 + secrets.randbelow(exclusive_upper_bound=900000))
# save process rule
if not dataset_process_rule:
process_rule = knowledge_config.process_rule