Skip to content

Add raw JSON and YAML import/export/edit capabilities#346

Open
jbms wants to merge 1 commit into
doy:mainfrom
jbms:main
Open

Add raw JSON and YAML import/export/edit capabilities#346
jbms wants to merge 1 commit into
doy:mainfrom
jbms:main

Conversation

@jbms
Copy link
Copy Markdown

@jbms jbms commented May 29, 2026

Add support for managing Bitwarden entries using raw JSON or YAML structures.
This enables advanced workflows like batch importing, editing complex entries
(e.g., cards, identities, SSH keys) with custom fields, and managing password
history directly from the command line or via automation scripts.

Key changes:

  • Add --raw (JSON) and --yaml (YAML) options to rbw add and rbw edit.
  • Add --yaml option to rbw get.
  • Implement strict validation for raw structures:
    • Prevent unrecognized fields using deny_unknown_fields on all decrypted structs.
    • Enforce mandatory fields (Field Name, Field Value, and Field Type) in DecryptedField
      by refactoring them to non-Option types, ensuring compile-time and runtime strictness.
  • Automatically generate a rich JSON Schema at runtime in YAML mode:
    • Write it to schema.json in the temp editing directory.
    • Inject the # yaml-language-server: $schema=./schema.json comment at the
      top of the YAML buffer to enable autocompletion and tooltips in editors.
    • Add descriptive titles and detailed tooltips to all schema fields.
  • Format all multi-line strings (such as notes and SSH private keys) using
    YAML block literals (|) automatically.
  • Ensure --raw and --yaml flags are mutually exclusive across all commands.
  • Expand library layer (Client::add, rbw::actions::add) to support custom
    fields, history, organization IDs, and different entry types when adding.
  • Clean up display logic in commands.rs by introducing display_custom_field
    helper, eliminating over 50 lines of duplicate boilerplate loops.
  • Add robust unit tests test_raw_yaml_serde and test_strict_validation to
    verify serialization, block literals, schema generation, and strict validation failures.
  • Update deny.toml to allow multiple versions of indexmap to coexist (due to schemars depending on v1 and petgraph/serde_yaml depending on v2).
  • Fix various Clippy lints including doc-markdown backticks, ref-option/trivially-copy-pass-by-ref allowed for serde helpers, and useless let-if sequences replaced with idiomatic if-let expressions.

@jbms jbms force-pushed the main branch 2 times, most recently from e8caa86 to dba2ea5 Compare May 30, 2026 04:15
Add support for managing Bitwarden entries using raw JSON or YAML structures.
This enables advanced workflows like batch importing, editing complex entries
(e.g., cards, identities, SSH keys) with custom fields, and managing password
history directly from the command line or via automation scripts.

Key changes:
- Add `--raw` (JSON) and `--yaml` (YAML) options to `rbw add` and `rbw edit`.
- Add `--yaml` option to `rbw get`.
- Implement strict validation for raw structures:
  - Prevent unrecognized fields using `deny_unknown_fields` on all decrypted structs.
  - Enforce mandatory fields (Field Name, Field Value, and Field Type) in `DecryptedField`
    by refactoring them to non-Option types, ensuring compile-time and runtime strictness.
- Automatically generate a rich JSON Schema at runtime in YAML mode:
  - Write it to `schema.json` in the temp editing directory.
  - Inject the `# yaml-language-server: $schema=./schema.json` comment at the
    top of the YAML buffer to enable autocompletion and tooltips in editors.
  - Add descriptive titles and detailed tooltips to all schema fields.
- Format all multi-line strings (such as notes and SSH private keys) using
  YAML block literals (`|`) automatically.
- Ensure `--raw` and `--yaml` flags are mutually exclusive across all commands.
- Expand library layer (`Client::add`, `rbw::actions::add`) to support custom
  fields, history, organization IDs, and different entry types when adding.
- Clean up display logic in `commands.rs` by introducing `display_custom_field`
  helper, eliminating over 50 lines of duplicate boilerplate loops.
- Add robust unit tests `test_raw_yaml_serde` and `test_strict_validation` to
  verify serialization, block literals, schema generation, and strict validation failures.
- Update deny.toml to allow multiple versions of indexmap and hashbrown to coexist (due to schemars depending on v1 and petgraph/serde_yaml depending on v2).
- Upgrade rustls-webpki (to v0.103.13), bytes (to v1.11.1), and rand (to v0.8.6 and v0.9.4) to patched versions in Cargo.lock to resolve cargo-deny security advisories, and update deny.toml to skip the new rand versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant