-
Notifications
You must be signed in to change notification settings - Fork 405
Final_fixes #101
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?
Final_fixes #101
Conversation
Improve Docker Build Process
Resolve long outstanding issues
Summary of ChangesHello @wesleykirkland, 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 introduces a series of critical updates and enhancements across the OpenHealth application. It focuses on bolstering the application's infrastructure with robust health checks and updated dependencies, streamlining the initial data seeding process, and refining API key handling for external LLM services. Furthermore, it significantly improves the reliability and performance of document parsing functionalities and enhances the user experience for file uploads. 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
|
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 several features and fixes, including dependency updates, Docker configuration improvements with healthchecks, and a new database seeding script. It also refactors the document parsing logic, removing direct filesystem access in favor of URL fetching and adding better error handling. However, there are significant security concerns. A critical regression is the removal of API key encryption, which now stores sensitive keys in plaintext in the database. Additionally, the new seed script uses a hardcoded, weak password. I've also noted a potential issue with a Docker service dependency condition and a possible regression in language support for OCR.
| let apiKey: string | ||
| if (currentDeploymentEnv === 'local') { | ||
| apiKey = decrypt(llmProvider.apiKey) | ||
| apiKey = llmProvider.apiKey |
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.
This change removes the decryption of the LLM provider's API key. Storing and handling API keys in plaintext is a critical security vulnerability. The key should be stored encrypted and decrypted only when it's about to be used. Please restore the call to decrypt().
| apiKey = llmProvider.apiKey | |
| apiKey = decrypt(llmProvider.apiKey) |
| } catch (e) { | ||
| apiKey = '' | ||
| } | ||
| let apiKey: string = llmProvider.apiKey |
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.
This change removes the decryption of the API key. This appears to be related to a broader removal of API key encryption, which is a critical security vulnerability. API keys must be stored encrypted at rest and only decrypted in memory when needed for an API call. Please restore the decryption logic.
let apiKey: string
try {
apiKey = decrypt(llmProvider.apiKey)
} catch (e) {
apiKey = ''
}| ) { | ||
| const {id} = await params | ||
| const body: LLMProviderPatchRequest = await req.json() | ||
|
|
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.
Storing API keys in plaintext is a critical security vulnerability. The encryption for the apiKey was removed before saving it to the database. If the database is ever compromised, all user API keys will be exposed. The previous implementation correctly used encrypt() to secure these keys at rest. This encryption logic must be restored.
// API key encryption
if (body.apiKey) body.apiKey = encrypt(body.apiKey)|
|
||
| return {...provider, apiKey: decryptedApiKey} | ||
| }) | ||
| }) |
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.
This change removes the decryption of API keys. While the goal might have been to stop sending keys to the client (which is good), the underlying issue is that this is part of a move to store API keys in plaintext in the database. This is a critical security vulnerability. Keys must be encrypted at rest. Please ensure encryption is used for storage and decryption is used server-side when making API calls.
})
.map((provider) => {
let decryptedApiKey: string
try {
decryptedApiKey = decrypt(provider.apiKey)
} catch (e) {
decryptedApiKey = ''
}
return {...provider, apiKey: decryptedApiKey}
}|
|
||
| async function main() { | ||
| // Create a default user for testing | ||
| const hashedPassword = await hash('password', 10) |
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.
Using a hardcoded, simple password like "password" in a seed script is a security risk. While this might be for a development environment, there's a danger of this script being run against a staging or production-like environment, creating a user with a well-known weak password. It's better to use a more secure, randomly generated password or pull it from an environment variable.
| const hashedPassword = await hash('password', 10) | |
| const hashedPassword = await hash(process.env.DEMO_USER_PASSWORD || 'a_much_more_secure_default_password_!@#$', 10) |
| docling-serve: | ||
| condition: service_started |
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.
The app service depends on docling-serve with condition: service_started. However, the docling-serve service has a healthcheck defined. Using condition: service_healthy would be more robust, as it ensures docling-serve is not just started, but is actually ready to accept requests before the app service starts. This can prevent race conditions and startup errors.
docling-serve:
condition: service_healthy| formData.append('force_ocr', 'false'); | ||
| formData.append('force_ocr', options.forceOcr ? 'true' : 'false'); | ||
| formData.append('image_export_mode', 'placeholder'); | ||
| formData.append('ocr_lang', 'en'); |
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.
The previous implementation included support for Korean OCR by passing ocr_lang: 'ko'. This has been removed in the refactoring. If Korean language support is still a requirement for document parsing, this should be added back.
| formData.append('ocr_lang', 'en'); | |
| formData.append('ocr_lang', 'en'); | |
| formData.append('ocr_lang', 'ko'); |
Add in additional features/fixes for OpenHealth