Menu ▾ ▴

#109 [Feature]: Edit environment secrets in a terminal editor

closed
nobody
2026-10-07
2026-10-05
Anonymous
No

Originally created by: thomijasir

Feature Description

Add dopbase env edit <ENVIRONMENT_REF> to edit a whole environment as .env text in an installed terminal editor, including Vim, Neovim, Helix, and nano.

Problem / Motivation

Changing several secrets with individual secret set commands is slow. Bulk import works, but users must export values, manage a plaintext file, edit it, preview it, and import it themselves. The UI already offers whole-environment editing.

An editor command brings that workflow to terminal users and lets developers use familiar search, replacement, and navigation shortcuts. Dopbase manages authentication, validation, previews, concurrency protection, and temporary-file cleanup.

Proposed Solution

  • Select an editor using --editor, $VISUAL, or $EDITOR, with installed-editor fallback.
  • Resolve the environment and list secret metadata before password confirmation.
  • If an existing environment is empty, offer to add secrets with No as the default. Declining exits without exporting values or opening an editor.
  • Require password confirmation for existing sessions before fetching plaintext. A login completed during this invocation counts as confirmation.
  • Open a private temporary .env file in a protected editor session.
  • Parse the edited content without shell execution or variable expansion, then run the existing server dry run.
  • Preview added, updated, and deleted key names without printing values outside the editor.
  • Remove editor files before submitting a confirmed draft through the existing atomic replace import. Wait for the save result if interrupted after submission starts.
  • Protect against concurrent changes both while editing and between preview and apply.
  • Removing a line schedules deletion; deleting every secret requires typing the environment reference.
  • Preserve comments and ordering using the existing value-free layout. Comments are unencrypted metadata and must not contain credentials.
  • Support --dry-run, reopening invalid edits, and cancellation without server changes.

Security and Compatibility

Use private session directories and owner-only files. Launch editors without a shell, exclude credentials from the child environment, and use protected profiles for known editors. Custom editor commands require acknowledgement before fetching values. Reject symlinks and unsafe file replacements when reading edited content.

Clean up on completion, cancellation, errors, and handled signals. Remove abandoned, unlocked sessions on a later invocation. Avoid logging plaintext and clear owned value buffers where practical. Document that external editors receive plaintext, forced termination can leave files behind, and deleting files does not guarantee forensic erasure.

Extend export with a consistent snapshot revision and layout. Validate expected revisions during dry runs as well as apply. Validate value-free layout on the server. Fail safely against older servers without snapshot support. Initial support targets the released Linux and macOS platforms; no database migration is needed.

Acceptance Criteria

  • [ ] Developers can edit, add, and delete several keys with dopbase env edit.
  • [ ] Missing targets and declined empty environments exit before password confirmation, plaintext export, and editor creation.
  • [ ] Existing sessions always require confirmation; a fresh login does not ask for the password twice.
  • [ ] Parsing and server validation finish before saving; previews contain key names and counts only.
  • [ ] Saving requires confirmation; cancellation and editor failures never apply edits.
  • [ ] Concurrent changes reject stale edits instead of overwriting newer secrets.
  • [ ] Comments and ordering survive future CLI and UI sessions without persisting values in layout.
  • [ ] Protected editor launch, permissions, file replacement, cleanup, redaction, and credential exclusion have tests.
  • [ ] Existing parser, import, export, authorization, and terminal tests are extended without duplicate coverage.
  • [ ] CLI help, documentation, and the release changelog explain the workflow and security limits.

Alternatives Considered

Individual secret set commands remain useful for a single value. Export/edit/import already supports bulk work but leaves more steps and plaintext-file handling to users. The web editor is available to browser users.

Additional Context

Related: [#35] proposes a dedicated secret-management TUI. This feature uses an external editor and the existing .env workflow; it does not introduce a terminal UI framework or replace that proposal.

Implement from release/0.1.9.

Related

Tickets: #111
Tickets: #35

Discussion

  • Anonymous

    Anonymous - 2026-10-07

    Ticket changed by: dopbase

    • status: open --> closed
     

Log in to post a comment.