← Back to Pull requests

fix(vault): validate origin and authenticator key as they are typed in `vault add` #136650

Open
unknown opened this pull request with 511 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 11, 2026 14:33 UTC
Author

What does this PR do?

hermes vault add validates the site origin and the authenticator key only inside VaultStore.add_item(), after every prompt has been answered — including the hidden password and 2FA key. A schemeless origin such as example.com is accepted at its prompt, and the wizard then fails at the very end, so the user has to retype the whole item.

Each validated field is now checked right where it is typed, with the same normalize_origin / normalize_otp_secret that add_item() applies, and the wizard prints the cause and re-asks that field only. add_item() keeps its own validation, so non-interactive callers (Desktop RPC, browser_vault_save_login) are unchanged.

Repro (temp HERMES_HOME, real _cmd_add, scripted input/getpass answers: site, example.com, https://example.com, email, user@example.com, password, empty 2FA):

origin/main — the bad origin is accepted, the next answer lands in the wrong prompt, and the error only appears after the password and 2FA key:

Site origin (e.g. https://github.com): example.com
Identifier type (email/phone/username) [email]: https://example.com
Identifier type (email/phone/username) [email]: email
Email: user@example.com
Password (hidden):
Authenticator key (optional, hidden; ...):
Error: origin must include a scheme (got 'example.com')

this branch:

Site origin (e.g. https://github.com): example.com
origin must include a scheme (got 'example.com')
Site origin (e.g. https://github.com): https://example.com
Identifier type (email/phone/username) [email]: email
Email: user@example.com
Password (hidden):
Authenticator key (optional, hidden; ...):
Stored. handle=vault_… kind=login origin=https://example.com

Related Issue

Fixes #136673

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • Changes Made

  • hermes_cli/vault.py::_prompt_valid — new helper: reads a field, runs the validator, and on VaultError prints the message and re-prompts.

  • hermes_cli/vault.py::_cmd_add — uses it for every field add_item() validates beyond non-empty: the login origin, the authenticator key (still optional, Enter skips), and the payment/address origin.

  • tests/hermes_cli/test_vault_add_inline_validation.py — two invariant tests (bad origin, bad authenticator key), each re-prompted before the next field and the item then stored; both fail on origin/main.
  • How to Test

    1. hermes vault add → kind login → enter an origin without https://.
    2. The error prints immediately and the origin prompt repeats; same for an invalid authenticator key.
    3. scripts/run_tests.sh tests/hermes_cli/test_vault_add_inline_validation.py

    Checklist

    Code

  • I've read the Contributing Guide

  • My commit messages follow Conventional Commits

  • I searched for existing PRs to make sure this isn't a duplicate

  • My PR contains only changes related to this fix/feature (no unrelated commits)

  • I've run pytest tests/ -q and all tests pass — via scripts/run_tests.sh: the vault files pass (54/54); on macOS the full suite also has failures in unrelated files (MCP, local jobs, web server, compaction) that fail the same way on origin/main or trip the home-I/O guard on a host-installed tool, none touch the vault

  • python scripts/check passes

  • I've added tests for my changes

  • I've tested on my platform: macOS (Darwin 27); the wizard is plain input/getpass, no platform-specific code
  • Documentation & Housekeeping

  • I've updated relevant documentation — N/A (prompts unchanged)

  • I've updated cli-config.yaml.example — N/A

  • I've updated CONTRIBUTING.md or AGENTS.md — N/A

  • I've considered cross-platform impact — N/A (no file I/O, process or terminal handling changes)

  • I've updated tool descriptions/schemas — N/A
  • 🤖 Generated with Claude Code

    Diff: 511 lines (+383 / -128) across 6 files Reviewer: PRATHAMESH75 Review duration: 76922m
    All Vouch review confidence checks passed
    Residual risk 0.45 = Change Risk (0.78) × (1 − Review Confidence (0.42)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.78 · 511 lines diff across 6 files
    0.78
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.373
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.078
    Real PR Conversation Timeline
    1 comments
    "Review active on #136650"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 42.2% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 77.8% (HIGH) · Higher = larger blast radius
    77.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 42.2% · Lower = rushed or shallow review
    42.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 45.0% · Moderate risk
    45.0%