RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(security): generate random UUIDv4 identifiers (#19159)
Sbaaoui Idriss330b988b61b0
diff --git a/api/db/joint_services/user_account_service.py b/api/db/joint_services/user_account_service.pyindex 32b95781b8..a6dee212eb 100644--- a/api/db/joint_services/user_account_service.py+++ b/api/db/joint_services/user_account_service.py@@ -16,6 +16,8 @@import loggingimport uuid+from common.misc_utils import get_uuid+from api.utils.api_utils import group_byfrom api.db import FileType, UserTenantRolefrom api.db.services.api_service import APITokenService, API4ConversationService@@ -56,9 +58,9 @@ def create_new_user(user_info: dict) -> dict:}"""# generate user_id and access_token for user- user_id = uuid.uuid1().hex+ user_id = get_uuid()user_info["id"] = user_id- user_info["access_token"] = uuid.uuid1().hex+ user_info["access_token"] = uuid.uuid4().hex# construct tenant infotenant = {"id": user_id,@@ -77,7 +79,7 @@ def create_new_user(user_info: dict) -> dict:"role": UserTenantRole.OWNER,}# construct file folder info- file_id = uuid.uuid1().hex+ file_id = get_uuid()file = {"id": file_id,"parent_id": file_id,diff --git a/test/unit_test/common/test_misc_utils.py b/test/unit_test/common/test_misc_utils.pyindex 9cd3f0fbf0..d7137ba88f 100644--- a/test/unit_test/common/test_misc_utils.py+++ b/test/unit_test/common/test_misc_utils.py@@ -181,7 +181,7 @@ class TestGetUuid:def test_hex_format(self):"""Test that returned string is in hex format"""result = get_uuid()- # UUID v1 hex should be 32 characters (without dashes)+ # UUID hex should be 32 characters (without dashes)assert len(result) == 32# Should only contain hexadecimal charactersassert all(c in "0123456789abcdef" for c in result)@@ -214,15 +214,11 @@ class TestGetUuid:# The hex representation should match the originalassert reconstructed_uuid.hex == result- def test_uuid1_specific_characteristics(self):- """Test that UUID v1 characteristics are present"""+ def test_uuid1_characteristics(self):+ """Generated identifiers are RFC 4122 UUIDv1 values."""result = get_uuid()uuid_obj = uuid.UUID(hex=result)-- # UUID v1 should have version 1assert uuid_obj.version == 1-- # Variant should be RFC 4122assert uuid_obj.variant == "specified in RFC 4122"def test_result_length_consistency(self):@@ -235,8 +231,8 @@ class TestGetUuid:"""Test that only valid hex characters are used"""for _ in range(100):result = get_uuid()- # Should only contain lowercase hex characters (UUID hex is lowercase)- assert result.islower()+ # Should only contain lowercase hexadecimal characters+ assert result == result.lower()assert all(c in "0123456789abcdef" for c in result)