mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Isolate test profiles
This commit is contained in:
@@ -22,6 +22,13 @@ SRC_DIR = PROJECT_ROOT / "src"
|
|||||||
if str(SRC_DIR) not in sys.path:
|
if str(SRC_DIR) not in sys.path:
|
||||||
sys.path.insert(0, str(SRC_DIR))
|
sys.path.insert(0, str(SRC_DIR))
|
||||||
|
|
||||||
|
import constants as consts
|
||||||
|
|
||||||
|
# Use a dedicated subdirectory for test profiles so regular data is not polluted
|
||||||
|
consts.APP_DIR = consts.APP_DIR / "tests"
|
||||||
|
consts.PARENT_SEED_FILE = consts.APP_DIR / "parent_seed.enc"
|
||||||
|
consts.SCRIPT_CHECKSUM_FILE = consts.APP_DIR / "seedpass_script_checksum.txt"
|
||||||
|
|
||||||
from constants import APP_DIR, initialize_app
|
from constants import APP_DIR, initialize_app
|
||||||
from utils.key_derivation import derive_key_from_password, derive_index_key
|
from utils.key_derivation import derive_key_from_password, derive_index_key
|
||||||
from password_manager.encryption import EncryptionManager
|
from password_manager.encryption import EncryptionManager
|
||||||
@@ -31,6 +38,8 @@ from password_manager.backup import BackupManager
|
|||||||
from password_manager.entry_management import EntryManager
|
from password_manager.entry_management import EntryManager
|
||||||
from nostr.client import NostrClient
|
from nostr.client import NostrClient
|
||||||
from utils.fingerprint import generate_fingerprint
|
from utils.fingerprint import generate_fingerprint
|
||||||
|
from utils.fingerprint_manager import FingerprintManager
|
||||||
|
import bcrypt
|
||||||
import asyncio
|
import asyncio
|
||||||
import gzip
|
import gzip
|
||||||
|
|
||||||
@@ -52,7 +61,12 @@ def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path, str]
|
|||||||
seed_txt.write_text(seed_phrase)
|
seed_txt.write_text(seed_phrase)
|
||||||
seed_txt.chmod(0o600)
|
seed_txt.chmod(0o600)
|
||||||
|
|
||||||
fingerprint = generate_fingerprint(seed_phrase) or profile_name
|
fp_mgr = FingerprintManager(APP_DIR)
|
||||||
|
fingerprint = fp_mgr.add_fingerprint(seed_phrase) or generate_fingerprint(
|
||||||
|
seed_phrase
|
||||||
|
)
|
||||||
|
if fingerprint is None:
|
||||||
|
fingerprint = profile_name
|
||||||
profile_dir = APP_DIR / fingerprint
|
profile_dir = APP_DIR / fingerprint
|
||||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
profile_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
@@ -79,6 +93,9 @@ def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path, str]
|
|||||||
enc_mgr = EncryptionManager(index_key, profile_dir)
|
enc_mgr = EncryptionManager(index_key, profile_dir)
|
||||||
vault = Vault(enc_mgr, profile_dir)
|
vault = Vault(enc_mgr, profile_dir)
|
||||||
cfg_mgr = ConfigManager(vault, profile_dir)
|
cfg_mgr = ConfigManager(vault, profile_dir)
|
||||||
|
# Store the default password hash so the profile can be opened
|
||||||
|
hashed = bcrypt.hashpw(DEFAULT_PASSWORD.encode(), bcrypt.gensalt()).decode()
|
||||||
|
cfg_mgr.set_password_hash(hashed)
|
||||||
backup_mgr = BackupManager(profile_dir, cfg_mgr)
|
backup_mgr = BackupManager(profile_dir, cfg_mgr)
|
||||||
entry_mgr = EntryManager(vault, backup_mgr)
|
entry_mgr = EntryManager(vault, backup_mgr)
|
||||||
return seed_phrase, entry_mgr, profile_dir, fingerprint
|
return seed_phrase, entry_mgr, profile_dir, fingerprint
|
||||||
@@ -132,7 +149,7 @@ def main() -> None:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--profile",
|
"--profile",
|
||||||
default="test_profile",
|
default="test_profile",
|
||||||
help="profile name inside ~/.seedpass",
|
help="profile name inside ~/.seedpass/tests",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--count",
|
"--count",
|
||||||
|
Reference in New Issue
Block a user