Skip to content

feat(NODE-6507): generate encryption configuration on mongoose connect #15320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 15, 2025

Conversation

baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Mar 18, 2025

Summary

This PR contains the meat and potatoes of the automatic CSFLE/QE integration into mongoose. With the changes included, users can now create encrypted schemas, instantiate models with them, insert and query using their model and have the resultant documents be encrypted and decrypted automatically.

This PR contains a lot of test changes. I tried to be as exhaustive to ensure as much coverage as possible, and because the schema format is unlikely to change (changing the format of encryptedFieldsMap or schemaMap would break a lot of drivers and applications). So ideally these tests are not a large maintenance burden.

Examples

See the integration tests in encryption.test.ts for an example of how the API works.

@baileympearson baileympearson marked this pull request as ready for review March 18, 2025 16:50
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

I'd also like to see tests covering:

  1. Subdocuments
  2. Document arrays
  3. Maps

If you can do CSFLE with nested paths, you should be able to also do CSFLE with subdocuments, which are slightly different.

@baileympearson
Copy link
Contributor Author

I'd also like to see tests covering:

  • Subdocuments
  • Document arrays
  • Maps
    If you can do CSFLE with nested paths, you should be able to also do CSFLE with subdocuments, which are slightly different.

I believe I now have tests for all of these. Let me know if I'm still missing anything

}
}

function* allNestedPaths(schema) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a neat use case for generators, but I think doing [...Object.keys(schema.paths), ...Object.keys(schema.singleNestedPaths)] would be more concise and more consistent with the rest of the codebase

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

Will merge into csfle branch

@vkarpov15 vkarpov15 merged commit 2fc58da into Automattic:csfle Apr 15, 2025
40 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