Skip to content

doc: Better doc around encryption#19

Merged
pimpin merged 1 commit intomasterfrom
fix_doc_arrount_encryption
Oct 14, 2025
Merged

doc: Better doc around encryption#19
pimpin merged 1 commit intomasterfrom
fix_doc_arrount_encryption

Conversation

@pimpin
Copy link
Collaborator

@pimpin pimpin commented Oct 10, 2025

Fix encryption documentation to reflect actual implementation

Summary

The :encrypted type documentation was misleading, claiming that CouchbaseOrm performs encryption/decryption automatically. In reality, it only provides a
storage format wrapper - applications must handle encryption themselves.

Changes

README.md

  • Added explicit warning that CouchbaseOrm does not perform encryption/decryption
  • Clarified that values must be Base64-encoded pre-encrypted ciphertext
  • Added link to detailed encryption documentation

docs/tutorial-ruby-couchbase-orm/11-encryption.md

  • Rewrote introduction to clarify ORM only provides storage format
  • Updated section 11.1 to explain alg parameter is informational only
  • Replaced misleading section 11.2 with complete working example showing:
    • Application-side encryption with OpenSSL
    • Base64 encoding/decoding
    • Full encrypt → save → load → decrypt workflow
  • Rewrote section 11.3 to clearly distinguish ORM responsibilities (format wrapping) from application responsibilities (actual encryption)
  • Enhanced section 11.4 with detailed best practices:
    • Key management and security recommendations
    • Implementation patterns with getter/setter accessors
    • Performance considerations and limitations

Key Points

  • Before: Documentation claimed automatic encryption with "configured encryption key"
  • After: Documentation correctly states application must provide pre-encrypted values
  • No code changes - purely documentation corrections to match actual implementation

@gemini-code-assist
Copy link

Summary of Changes

Hello @pimpin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses critical inaccuracies in the CouchbaseOrm documentation regarding the :encrypted attribute type. The previous documentation incorrectly implied that CouchbaseOrm handled automatic encryption and decryption. The updated documentation now clearly defines that CouchbaseOrm provides only a structured storage format for encrypted data, placing the responsibility for actual encryption and decryption squarely on the application. This ensures users have a precise understanding of how to implement secure data storage with the ORM.

Highlights

  • Clarified Encryption Responsibilities: The documentation for the :encrypted type in CouchbaseOrm has been updated to explicitly state that the ORM only provides a storage format compatible with Couchbase Lite field-level encryption, and does not perform encryption or decryption itself. Applications are responsible for handling the actual encryption and decryption process.
  • Updated README.md: The main README file now includes an explicit warning about CouchbaseOrm's role in encryption, clarifies that values must be Base64-encoded pre-encrypted ciphertext, and links to the more detailed encryption documentation.
  • Rewritten Encryption Tutorial: The 11-encryption.md tutorial has been completely revised to reflect the correct implementation. It now includes a comprehensive working example demonstrating application-side encryption/decryption using OpenSSL, details the storage format, and provides extensive best practices for security, key management, performance, and implementation patterns.
  • No Code Changes: This pull request is purely a documentation update, correcting misleading information without altering any core application code.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pimpin pimpin requested a review from teetangh October 10, 2025 15:27
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the documentation around encryption by clarifying that CouchbaseOrm only provides a storage format and does not handle encryption/decryption itself. The changes in README.md and the detailed 11-encryption.md guide are excellent, providing clear warnings, correct usage patterns, and a complete working example. My feedback includes a couple of minor suggestions to further enhance the clarity and security guidance of the code examples in the documentation.

# This is a simplified example - use a proper encryption library in production
cipher = OpenSSL::Cipher.new('AES-256-CBC')
cipher.encrypt
cipher.key = ENV['ENCRYPTION_KEY'] # Store securely, never commit to git

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The example uses AES-256-CBC, which requires a 32-byte (256-bit) encryption key. While OpenSSL might pad or truncate a key of incorrect length, this can lead to security vulnerabilities if not handled carefully. It would be beneficial to explicitly state the required key length in a comment to guide users towards better security practices.

Suggested change
cipher.key = ENV['ENCRYPTION_KEY'] # Store securely, never commit to git
cipher.key = ENV['ENCRYPTION_KEY'] # Must be a 32-byte (256-bit) key. Store securely, never commit to git

end

def account_number
encrypted = Base64.strict_decode64(super)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In this getter override example, super is used without parentheses. While this works correctly here, the following example in the "Separate concerns" section (line 188) uses super(). Using super() is more explicit that you are calling the parent method with no arguments. For consistency and clarity across the documentation, it would be better to use super() in this example as well.

Suggested change
encrypted = Base64.strict_decode64(super)
encrypted = Base64.strict_decode64(super())

@pimpin pimpin merged commit 1110ee8 into master Oct 14, 2025
9 of 10 checks passed
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.

2 participants