-
Notifications
You must be signed in to change notification settings - Fork 10
GH-451: [Storage] Container baked with Document Data in MongoDB #452
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
base: main
Are you sure you want to change the base?
Conversation
…e build-time data ingestion for MongoDB.
Summary of ChangesHello @vibhatha, 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 significantly enhances the deployment of MongoDB and Neo4j services by implementing a build-time data ingestion strategy. Instead of restoring data at container runtime, the Docker images are now pre-populated with essential document and graph data during their construction. This change streamlines the container startup process, ensuring that instances are immediately operational with the necessary datasets, and standardizes data paths for both databases. Highlights
Using Gemini Code AssistThe 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
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 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
|
…mp to root, and import path to /var/lib/neo4j/import.
There was a problem hiding this 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 introduces build-time data ingestion for the MongoDB container, aligning it with the setup for other databases in the project. This involves modifying the MongoDB Dockerfile to use /tmp/db for data, and adding a new RUN step to download and restore a database backup during the image build. The Neo4j Dockerfile is also updated to use /tmp for its directories.
My review focuses on the new functionality in the MongoDB Dockerfile. I've identified a logic bug that causes a function to report failure on success, and several critical security vulnerabilities where credentials are exposed on the command line during the build process. The feedback provides specific suggestions to address these issues.
| # Clean up backup files\n\ | ||
| rm -rf /data/backup/opengin\n\ | ||
| rm -rf "$temp_dir"\n\ | ||
| return 1\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| until mongo --eval "db.adminCommand('ping')" > /dev/null 2>&1; do sleep 1; done && \ | ||
| \ | ||
| # Setup Admin User (so we can restore) | ||
| mongo admin --quiet --eval "db.createUser({user: '${MONGO_INITDB_ROOT_USERNAME}', pwd: '${MONGO_INITDB_ROOT_PASSWORD}', roles: [{role: 'root', db: 'admin'}]})" && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing the password as part of the --eval string exposes it in the process list, which is a security risk. This is also inconsistent with how a user is created in the entrypoint script (line 203), which uses a 'here string' (<<<) to pass the command via standard input. Please use a 'here string' here as well to avoid exposing credentials.
mongo admin --quiet <<< "db.createUser({user: '${MONGO_INITDB_ROOT_USERNAME}', pwd: '${MONGO_INITDB_ROOT_PASSWORD}', roles: [{role: 'root', db: 'admin'}]})" && \
References
- Avoid passing sensitive information like passwords as command-line arguments to prevent them from being exposed in the process list. Instead, use methods like here strings (
<<<) to pass the data via standard input, or write it to a temporary file that is securely handled and deleted.
| if [ -d "$temp_dir/restore_source/opengin/opengin" ]; then restore_path="$temp_dir/restore_source/opengin/opengin"; fi && \ | ||
| \ | ||
| echo "Running mongorestore from $restore_path..." && \ | ||
| mongorestore --host=localhost:27017 --username=${MONGO_INITDB_ROOT_USERNAME} --password=${MONGO_INITDB_ROOT_PASSWORD} --authenticationDatabase=admin --drop "$restore_path" && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing credentials via command-line arguments to mongorestore is a security risk as they can be exposed in the process list. This violates a general security rule for this repository.
While mongorestore has limitations in how it accepts credentials, this is a significant security concern. Please investigate more secure alternatives, such as checking if this version of mongorestore can read credentials from a file or environment variables.
References
- Avoid passing sensitive information like passwords as command-line arguments to prevent them from being exposed in the process list. Instead, use methods like here strings (
<<<) to pass the data via standard input, or write it to a temporary file that is securely handled and deleted.
| mongorestore --host=localhost:27017 --username=${MONGO_INITDB_ROOT_USERNAME} --password=${MONGO_INITDB_ROOT_PASSWORD} --authenticationDatabase=admin --drop "$restore_path" && \ | ||
| \ | ||
| echo "Shutting down MongoDB..." && \ | ||
| mongo admin --username=${MONGO_INITDB_ROOT_USERNAME} --password=${MONGO_INITDB_ROOT_PASSWORD} --authenticationDatabase=admin --eval "db.shutdownServer()" && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing credentials via command-line arguments is a security risk as they can be exposed in the process list. Instead of using --username and --password flags, you can use a 'here string' to pass an authentication command followed by the shutdownServer command to the mongo shell via standard input.
mongo admin --username=${MONGO_INITDB_ROOT_USERNAME} --password=${MONGO_INITDB_ROOT_PASSWORD} --authenticationDatabase=admin --quiet <<< "db.auth('${MONGO_INITDB_ROOT_USERNAME}', '${MONGO_INITDB_ROOT_PASSWORD}'); db.shutdownServer();" && \
References
- Avoid passing sensitive information like passwords as command-line arguments to prevent them from being exposed in the process list. Instead, use methods like here strings (
<<<) to pass the data via standard input, or write it to a temporary file that is securely handled and deleted.
This PR closes #451