Skip to content

Conversation

@victorvhs017
Copy link
Contributor

@victorvhs017 victorvhs017 commented Nov 18, 2025

Description 📣

Add Mongodb app connection and secret rotation to Infisical with their respective documentation.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

  • Test the mongodb app connection
  • Test with and with SSL
  • Test with regular mongo URI and mongodb+srv URIs
  • Check the app connection documentation
  • Test the mongodb secret rotation
  • Test with and with SSL
  • Test with regular mongo URI and mongodb+srv URIs
  • Check the secret rotation documentation

Victor Santos added 4 commits November 14, 2025 20:26
- Introduced MongoDB connection router and schemas.
- Updated app connection enums and maps to include MongoDB.
- Implemented validation and connection functions for MongoDB.
- Enhanced app connection service to handle MongoDB credentials.
- Implemented MongoDB connection form with validation and credential handling.
- Updated enums and maps to include MongoDB support across backend and frontend.
- Enhanced app connection schemas to accommodate MongoDB connection options.
- Integrated MongoDB connection handling in relevant components and hooks.
- Enhanced MongoDB connection handling in backend with improved host validation.
- Updated documentation to include MongoDB connection options and API references.
- Added new images for MongoDB connection forms and processes.
- Implemented MongoDB connection form in the frontend with necessary adjustments.
- Introduced MongoDB credentials rotation router and schemas.
- Updated backend services to handle MongoDB credentials rotation logic.
- Enhanced frontend components to support MongoDB credentials management.
- Integrated MongoDB credentials rotation into existing secret rotation options and forms.
@maidul98
Copy link
Collaborator

maidul98 commented Nov 18, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 18, 2025

Greptile Summary

  • Adds MongoDB connection support with username/password authentication, SSL/TLS configuration, and URL normalization for both standard and SRV connection strings
  • Implements secret rotation for MongoDB credentials using dual-user pattern (username1/username2) with password updates via updateUser command
  • Includes comprehensive documentation with user setup instructions, permission requirements, and UI/API configuration examples

Confidence Score: 3/5

  • This PR introduces regex usage that violates repository security policy requiring re2 for ReDoS prevention
  • The MongoDB feature implementation is solid with proper host validation via verifyHostInputValidity and good authorization patterns. However, two critical files use native JavaScript regex (.replace() with regex literals) instead of the required re2 package, creating potential ReDoS attack vectors. This violates Rule 1 from repository guidelines.
  • Fix native regex usage in backend/src/services/app-connection/mongodb/mongodb-connection-fns.ts and backend/src/ee/services/secret-rotation-v2/mongodb-credentials/mongodb-credentials-rotation-fns.ts before merging

Important Files Changed

Filename Overview
backend/src/services/app-connection/mongodb/mongodb-connection-fns.ts Adds MongoDB connection validation with host/URL normalization, but uses native regex which needs replacement with re2 to prevent ReDoS
backend/src/ee/services/secret-rotation-v2/mongodb-credentials/mongodb-credentials-rotation-fns.ts Implements MongoDB credentials rotation with password updates, but uses native regex which needs replacement with re2 to prevent ReDoS

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

50 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format

Victor Santos added 3 commits November 17, 2025 22:36
- Replaced string methods with RE2 regex for improved host validation in MongoDB connection functions.
- Updated the `mongodbCredentialsRotationFactory` and `validateMongoDBConnectionCredentials` to utilize regex for parsing connection strings.
- Enhanced code readability and maintainability by consolidating host normalization logic.
- Created comprehensive documentation for MongoDB credentials rotation, detailing setup and usage.
- Added new images to illustrate the MongoDB credentials rotation process in the UI.
- Updated existing documentation to include MongoDB in the secret rotation options and API references.
Copy link
Contributor

@scott-ray-wilson scott-ray-wilson left a comment

Choose a reason for hiding this comment

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

Looking good overall! few nits and comments

"documentation/platform/secret-rotation/ldap-password",
"documentation/platform/secret-rotation/mssql-credentials",
"documentation/platform/secret-rotation/mysql-credentials",
"documentation/platform/secret-rotation/mongodb-credentials",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: bump above mysql for alpha sorting

"environment": {
"slug": "dev",
"name": "Development",
"id": ""170a40f1-1b48-4cc7-addf-e563aa9fbe37"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: double quotes in front of uuid ""170...

},
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"folder": {
"id": ""b3257e1f-8d32-4e86-8bfd-b1f1bc1bf2c3"",
Copy link
Contributor

Choose a reason for hiding this comment

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

same here double wrapped quotes


let client: MongoClient | null = null;
try {
client = await $getClient();
Copy link
Contributor

Choose a reason for hiding this comment

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

for both issue and revoke I think we want to use a mongodb session (transaction) - that way if either command fails neither commits

Copy link
Contributor

Choose a reason for hiding this comment

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

If I misconfigure any of the fields that lead to an invalid connection I just eventually timeout and get an undefined error

CleanShot 2025-11-20 at 18 23 15@2x

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.

4 participants