Commit Graph
737 Commits
Author SHA1 Message Date
thePR0M3TH3AN 073b1065ca Handle unlock cancellation messages robustly in settings flow 2026-02-25 21:35:33 -05:00
thePR0M3TH3AN 882cd060fa Fix Python 3.10 compatibility for UTC timezone usage 2026-02-25 21:26:32 -05:00
thePR0M3TH3AN c25d1df78d Format files to satisfy CI black check 2026-02-25 21:22:39 -05:00
thePR0M3TH3AN 0f8a54342c Fix profile setup edge cases and TOTP viewer refresh 2026-02-25 20:57:29 -05:00
thePR0M3TH3AN 45550ebb6b Fix installer dependency resolution and refresh lockfile 2026-02-25 20:38:46 -05:00
thePR0M3TH3AN 88c1974ac6 Harden TUI recovery paths and add release integrity gates 2026-02-25 19:18:54 -05:00
thePR0M3TH3AN 72e6e3ba38 Close security item 6 with unlock throttling and policy gates 2026-02-25 18:32:06 -05:00
thePR0M3TH3AN 73a175b93f Harden item 6 API route access controls while locked 2026-02-25 18:29:02 -05:00
thePR0M3TH3AN dd6cbea7de Start security item 6: API lock access control and unlock route 2026-02-25 18:26:43 -05:00
thePR0M3TH3AN 56b68bd0ac Complete security item 3 hardening and redaction sweep 2026-02-25 18:23:40 -05:00
thePR0M3TH3AN fcbe2b2943 Harden security item 2: KDF policy, export safeguards, and tests 2026-02-25 18:15:51 -05:00
thePR0M3TH3AN c3eef44ab7 improved tests 2026-02-25 18:07:22 -05:00
thePR0M3TH3AN d83e16baf3 update 2026-02-25 17:30:25 -05:00
google-labs-jules[bot]andPR0M3TH3AN 4a1529fd1a Fix CI failures: linting and dependency vulnerabilities
- Apply code formatting fixes (black) to resolve test workflow failures.
- Update `pyproject.toml`, `src/requirements.txt`, and lock files to upgrade vulnerable dependencies:
  - aiohttp -> 3.13.3
  - cryptography -> 46.0.5
  - orjson -> 3.11.7 (CVE-2025-67221)
  - pillow -> 12.1.1 (CVE-2026-25990)
  - pynacl -> 1.6.2 (CVE-2025-69277)
  - starlette -> 0.52.1 (CVE-2025-62727)
  - urllib3 -> 2.6.3 (CVE-2025-66418, etc.)
  - cbor2 -> 5.8.0 (CVE-2025-68131)
  - pyasn1 -> 0.6.2 (CVE-2026-23490)
  - python-multipart -> 0.0.22 (CVE-2026-24486)
- Manually sync `requirements.lock` from `poetry.lock` as `pip-compile` is unavailable in the environment.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-25 19:24:01 +00:00
thePR0M3TH3AN 37d0dffdc3 Merge branch 'beta' into main (safe conflict resolution) 2026-02-23 16:38:18 -05:00
thePR0M3TH3AN 3ea37865cb Add landing install copy UX and document remaining security/test TODOs 2026-02-23 16:33:57 -05:00
thePR0M3TH3AN 0789dfcb55 Harden agent policy and API import limits; fix docs links 2026-02-23 16:24:53 -05:00
thePR0M3TH3AN 03958106e1 Add agent mode, hardened TUI harness, coverage gates, and cross-platform installer smoke CI
This commit delivers four related improvements focused on reliability and automation while preserving existing human/TUI workflows.

1) Agent-first CLI mode (additive)
- Added new `seedpass agent` command group (`src/seedpass/cli/agent.py`) and wired it into CLI root.
- Implemented non-interactive profile bootstrap: `seedpass agent init` with `--seed|--seed-file|--generate-seed` and password env injection (`--password-env`).
- Added policy management commands: `agent policy-show` and `agent policy-set` with allow/deny kind controls.
- Added JSON-based secret retrieval: `seedpass -f <fingerprint> agent get <query> --ttl <sec>` with lease metadata and policy enforcement.
- Kept regular human mode fully available; no behavioral changes to interactive TUI entrypoint.

2) TUI agent harness deepening and stabilization
- Refactored harness into scenario profiles: `core`, `extended`, `stress` with `--scenario` selection.
- Added deterministic seeded stress campaigns: `--stress-cycles`, `--stress-seed`.
- Added scenario-specific required coverage keys and report metadata.
- Added post-condition assertions in extended scenario (archive/restore consistency, lock/unlock retrieval recovery).
- Hardened prompt matching for output variants and fail-fast behavior on non-zero SeedPass exit codes.
- Added harness unit tests for helper logic and control flow.

3) Critical module coverage gate tooling
- Added `scripts/check_critical_coverage.py` to enforce per-module thresholds from coverage JSON and report uncovered functions.
- Added override controls (`--threshold`, `--no-default-thresholds`) and optional JSON result output.
- Integrated coverage JSON generation into CI helper script and optional gate execution via `CRITICAL_COVERAGE_GATE=1`.
- Tuned default thresholds using full-suite baseline and increased strictness:
  - `src/main.py >= 50%`
  - `src/seedpass/core/manager.py >= 60%`
  - `src/seedpass/core/encryption.py >= 80%`
  - `src/seedpass/core/migrations.py >= 90%`
- Added tests for coverage gate parser/analysis logic and targeted manager worker path tests.

4) Installer validation framework for beta/main
- Added cross-platform installer smoke scripts:
  - `scripts/installer_smoke_unix.sh`
  - `scripts/installer_smoke_windows.ps1`
- Added GitHub Actions workflow `.github/workflows/installer-smoke.yml` with:
  - reduced PR matrix
  - full scheduled/manual matrix across OS/branch/mode
  - per-job log capture and artifact uploads for failure triage
- Added installer testing documentation and linked from README.

Additional housekeeping
- Added `.venv/` to `.gitignore`.
- Updated docs for new harness scenarios, seeded stress mode, post-condition metadata, coverage gate usage, and installer testing workflow.
2026-02-23 15:47:59 -05:00
thePR0M3TH3AN dd7290e83b Add robust AI TUI harness, docs roadmap, and lock/unlock fix 2026-02-23 14:35:40 -05:00
thePR0M3TH3AN 39d3b72e66 Merge pull request #889 from PR0M3TH3AN/opt-totp-cache-13978863474736758588
⚡ Optimize TOTP display loop by caching derived secrets
2026-02-18 10:23:09 -05:00
google-labs-jules[bot]andPR0M3TH3AN 49c4da7ff0 Fix CI formatting failure and linting issues
- Reformatted `src/tests/helpers.py`, `src/tests/test_generate_test_profile_sync.py`, `src/tests/test_manifest_id_privacy.py`, and `src/tests/test_restore_from_nostr_setup.py` using `black`.
- Refactored `src/tests/helpers.py` to fix dispersed imports and remove unused imports (`time`, `asyncio`), resolving `flake8` warnings.
- Split long lines in `src/tests/helpers.py` to improve readability and compliance with style guides.
- Verified formatting with `black --check .`.
- Verified all tests pass with `pytest`.
- Confirmed `flake8` errors related to line length in `helpers.py` are acceptable as CI does not enforce strict 79-char limit (using `black` defaults).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 04:05:16 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1f92fe7901 Refactor test fixtures and fix linting issues
- Moved `client` and `dummy_nostr_client` fixtures to `src/tests/conftest.py` to fix F811 redefinition errors and improve test organization.
- Introduced `make_dummy_nostr_client` factory fixture to support tests requiring multiple client instances.
- Updated all affected tests to use the new fixture pattern.
- Removed deprecated `is_flag=True` from Typer boolean options in CLI modules.
- Fixed F541 (f-string without placeholders) in `entry_management.py`.
- Fixed F841 (unused variable) in `manager.py`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:39:55 +00:00
google-labs-jules[bot]andPR0M3TH3AN b0c3a97ce3 perf: Cache derived TOTP secrets in display loops
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:39:51 +00:00
thePR0M3TH3AN 98d30efc1e Merge pull request #881 from PR0M3TH3AN/test-api-services-18361836480733235045
Add tests for core API service classes
2026-02-16 13:20:11 -05:00
thePR0M3TH3AN 82b81aa79b Merge pull request #882 from PR0M3TH3AN/fix/scan-codebase-linting-12332732608299564025
Fix formatting and logic errors found during codebase scan
2026-02-16 13:19:33 -05:00
google-labs-jules[bot]andPR0M3TH3AN 1c5cf3e087 Fix formatting in test_core_api_services.py
Applied `black` formatting to `src/tests/test_core_api_services.py` to resolve CI linting failure.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 18:12:26 +00:00
google-labs-jules[bot]andPR0M3TH3AN 60b850b5bb Clean up repo-context.txt removing phantom EventHandler
The file src/nostr/event_handler.py does not exist in the codebase, and EventHandler is not used in src/nostr/client.py.
However, src/repo-context.txt incorrectly contained references to this file and usage.
This change updates src/repo-context.txt to remove the hallucinated/outdated code references, aligning the documentation with the actual codebase state.
Attempts to remove unused imports in src/nostr/client.py were reverted as tests rely on monkeypatching them.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 18:10:45 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8e33f9c5e1 Fix formatting, linting, and logic errors from codebase scan
- Apply black formatting to 17 files.
- Fix F821 undefined name errors in:
  - src/main.py: Add missing `queue` import.
  - src/seedpass/core/encryption.py: Fix `JSONDecodeError` reference.
  - src/utils/__init__.py: Fix exception variable scope in fallback code.
  - src/utils/key_derivation.py: Add `TYPE_CHECKING` imports.
  - src/seedpass/core/config_manager.py: Add `TYPE_CHECKING` imports.
- Initialize torch environment and TODO file.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 18:09:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN fe4344c21a Add comprehensive tests for core API service classes
Added `src/tests/test_core_api_services.py` to test public methods of
`VaultService`, `ProfileService`, `SyncService`, `EntryService`,
`ConfigService`, `UtilityService`, and `NostrService` in `src/seedpass/core/api.py`.

These tests ensure proper thread safety (locking) and delegation to
the underlying `PasswordManager` and its components.

Key improvements:
- Verified locking behavior for thread-safe operations.
- Validated delegation logic for all service methods.
- Covered edge cases like default vs. custom password generation policies.
- Mocked external dependencies (pubsub bus, manager components) to isolate service logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 18:09:03 +00:00
thePR0M3TH3AN 8094311219 Merge pull request #876 from PR0M3TH3AN/test-modify-entry-validation-4213307223161980339
🧪 Add validation tests for modify_entry
2026-02-16 12:49:31 -05:00
thePR0M3TH3AN b2a8fdefb0 Merge pull request #879 from PR0M3TH3AN/test-imghdr-stub-12332639906948512707
Add tests for imghdr_stub.py
2026-02-16 12:49:15 -05:00
thePR0M3TH3AN 10317aec03 Merge pull request #877 from PR0M3TH3AN/security-fix-token-timing-attack-14331876507002006471
🔒 Fix timing attack vulnerability in API token verification
2026-02-16 12:48:52 -05:00
thePR0M3TH3AN 48711a7320 Merge pull request #878 from PR0M3TH3AN/test-key-validation-coverage-8412470545867749142
🧪 Add error handling tests for key validation utils
2026-02-16 12:48:21 -05:00
thePR0M3TH3AN 9575ca1c7e Merge pull request #874 from PR0M3TH3AN/nostr-perf-concurrent-chunks-11272584633812719406
⚡ Concurrent Nostr snapshot chunk fetching
2026-02-16 12:47:58 -05:00
thePR0M3TH3AN 3b6325dc72 Merge pull request #872 from PR0M3TH3AN/code-health/remove-redundant-else-14874071705569730132
Refactor BIP85: Remove redundant elif block
2026-02-16 12:47:39 -05:00
google-labs-jules[bot]andPR0M3TH3AN 654f9c05a6 feat(test): add tests for imghdr_stub.py
Adds comprehensive tests for `src/utils/imghdr_stub.py` to ensure it correctly identifies image headers, covering all supported formats and edge cases. This is crucial as `imghdr` is removed in Python 3.13 and this stub is used by dependencies like `pgpy`.

- Added `src/tests/test_imghdr_stub.py` covering:
  - `what()` function with file paths, Path objects, file-like objects, and bytes.
  - All supported image formats (JPEG, PNG, GIF, TIFF, etc.).
  - Edge cases (empty file, short file, unknown type).
- Verified tests pass locally.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:47:23 +00:00
thePR0M3TH3AN 8b2534704f Merge pull request #875 from PR0M3TH3AN/refactor-file-lock-deduplication-16243706415213673778
Refactor file_lock.py to reduce code duplication
2026-02-16 12:47:00 -05:00
google-labs-jules[bot]andPR0M3TH3AN 3fd2470ccc Add error handling tests for key validation utils
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:45:53 +00:00
google-labs-jules[bot]andPR0M3TH3AN e59cc1af2e Fix timing attack vulnerability in token verification
Replaced insecure string comparison with `secrets.compare_digest` in `_check_token` to prevent timing attacks.
Added a test case for missing token to ensure robust error handling.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:44:02 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1f43f9f731 Add tests for modify_entry invalid fields validation
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:43:42 +00:00
google-labs-jules[bot]andPR0M3TH3AN 154fb8d9cd ⚡ Optimize Nostr snapshot retrieval with concurrent fetching
Refactored `_fetch_chunks_with_retry` in `src/nostr/client.py` to fetch snapshot chunks concurrently using `asyncio.gather`.
Introduced a `asyncio.Semaphore(10)` to limit concurrency and prevent overwhelming relays.
Extracted single chunk fetch logic into `_fetch_single_chunk` helper method.
Added `sys.path` fix to `src/tests/test_nostr_snapshot.py` to enable running tests.

Performance improvement: ~10x speedup for 10 chunks (1.0s -> 0.1s in local reproduction).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:43:30 +00:00
google-labs-jules[bot]andPR0M3TH3AN 267ac5c3ca Refactor src/utils/file_lock.py to reduce duplication
Extracts common logic for path preparation and lock acquisition into a private helper function `_get_portalocker_lock`. This simplifies `exclusive_lock` and `shared_lock` implementations.

Also updates the docstring for `exclusive_lock` to correctly describe the file mode as "binary read/write mode" (r+b) instead of "binary append mode".

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:43:29 +00:00
google-labs-jules[bot]andPR0M3TH3AN fe6334523c Remove unused EventHandler class and its tests
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:43:16 +00:00
google-labs-jules[bot]andPR0M3TH3AN 379d4ee98d Refactor BIP85: Remove redundant elif block
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:40:47 +00:00
google-labs-jules[bot]andPR0M3TH3AN afa35a1782 Optimize TOTP derivation in GUI loop by caching secrets
- Add `get_totp_secret` to `EntryManager` and `EntryService` to allow retrieving the secret (derived or imported) without calculating the code.
- Update `TotpViewerWindow` in GUI to cache TOTP secrets locally. This prevents expensive PBKDF2/BIP39 derivation on every UI refresh (every second).
- Clean up unused imports and f-strings in `entry_management.py`.

Benchmarks show a ~9x speedup for 10 frames (50 entries) and >100x speedup for steady state.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:37:03 +00:00
thePR0M3TH3AN 46f753a11a Merge pull request #870 from PR0M3TH3AN/fix-key-derivation-salt-12798847451274058286
🔒 Fix Weak Key Derivation by Adding Salt
2026-02-16 12:24:12 -05:00
thePR0M3TH3AN 8adc1e7220 Merge pull request #869 from PR0M3TH3AN/improve-inmemory-secret-error-handling-18204251655789169400
Improve InMemorySecret wiped state error handling and testing
2026-02-16 12:23:12 -05:00
google-labs-jules[bot]andPR0M3TH3AN 75fe5bc382 Fix weak key derivation by adding salt to parent seed encryption
Introduced a random salt to key derivation for parent seed encryption to prevent rainbow table attacks. The salt is now stored in the `parent_seed.enc` file header (V3 format).

*   Modified `src/utils/key_derivation.py` to accept optional `salt` argument.
*   Modified `src/seedpass/core/encryption.py` to read/write salt in `parent_seed.enc` using V3 format (V3:salt:nonce:ciphertext).
*   Modified `src/seedpass/core/manager.py` to generate salt for new seeds and read salt for existing ones.
*   Added auto-upgrade logic for legacy (no salt) seeds upon access.
*   Updated tests to verify salt usage and backward compatibility.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:22:54 +00:00
google-labs-jules[bot]andPR0M3TH3AN d729466513 test(utils): Add test and error handling for wiped InMemorySecret
- Updated `InMemorySecret.get_bytes()` in `src/utils/memory_protection.py` to raise a `RuntimeError` if the secret has been wiped, replacing the previous `AttributeError`.
- Added `test_access_after_wipe_raises_error` to `src/tests/test_memory_protection.py` to verify this behavior.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:21:45 +00:00
thePR0M3TH3AN 21c25a0b63 Merge pull request #868 from PR0M3TH3AN/security-fix-path-traversal-17059275168502501133
🔒 Security Fix: Arbitrary File Read via Path Traversal in import_vault
2026-02-16 12:21:21 -05:00