Skip to content

Commit 60f301c

Browse files
fix(core): correct PBKDF2HMAC import and session management
- Fix import name from PBKDF2 to PBKDF2HMAC (correct cryptography API) - Fix SQLAlchemy session detachment issue in list_projects() - Eagerly load relationships to prevent lazy load errors Tested on macOS - all functionality working correctly
1 parent 8a130a2 commit 60f301c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/core/storage.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ def list_projects(self) -> List[Project]:
8686
"""
8787
session = self.db_manager.get_session()
8888
try:
89-
return session.query(Project).order_by(Project.name).all()
89+
projects = session.query(Project).order_by(Project.name).all()
90+
# Eagerly load env_vars to avoid detached instance issues
91+
for project in projects:
92+
_ = len(project.env_vars) # Force load
93+
return projects
9094
finally:
9195
session.close()
9296

src/crypto/encryption.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from cryptography.fernet import Fernet, InvalidToken
1313
from cryptography.hazmat.primitives import hashes
14-
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2
14+
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
1515

1616

1717
class EncryptionManager:
@@ -45,7 +45,7 @@ def _derive_key(self, password: str, salt: bytes) -> bytes:
4545
Returns:
4646
A base64-encoded 32-byte key suitable for Fernet
4747
"""
48-
kdf = PBKDF2(
48+
kdf = PBKDF2HMAC(
4949
algorithm=hashes.SHA256(),
5050
length=32,
5151
salt=salt,

0 commit comments

Comments
 (0)