chore: Harden API image Node.js runtime install#30497
Conversation
…es from the 6.x line (Node 20/22), rather than the 5.x line (Node 18). ([npmjs.com](https://www.npmjs.com/undici?utm_source=openai)) - `api/Dockerfile`: added NodeSource repo setup and switched the `nodejs` install to Node 20. CVE-2023-24807 is a ReDoS in undici `Headers.set()`/`Headers.append()` and affects undici versions before 5.19.1. ([nvd.nist.gov](https://nvd.nist.gov/vuln/detail/CVE-2023-24807)) Based on the undici LTS/bundling table, Node 20 should bundle undici 6.x, which is newer than 5.19.1 and thus outside the affected range (inference). ([npmjs.com](https://www.npmjs.com/undici?utm_source=openai)) Tests not run (Dockerfile change only). Next steps: 1. Rebuild the API image and verify `node -p "process.versions.undici"` is >= 5.19.1. 2. Re-run your Docker Scout scan.
…e NodeSource key fingerprint before trusting it and pinning the exact `nodejs` package version so builds are deterministic. This keeps NodeSource (for Node 20) while tightening supply‑chain trust. - Added `ARG` pins and fingerprint check, then install `nodejs=${NODE_PACKAGE_VERSION}` in `api/Dockerfile`. - NodeSource key is now verified against `NODESOURCE_KEY_FPR` before it’s written to `/etc/apt/keyrings`. Tests not run (Dockerfile change only). If there’s no hard requirement for NodeSource, I can switch to Debian’s `nodejs` packages instead to reduce the trusted supply chain surface. Next steps: 1. Rebuild the API image to confirm the pinned version is available and installs cleanly. 2. Let me know if you want to drop NodeSource and use Debian’s `nodejs` packages instead. Summary of ChangesHello @laipz8200, 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 robustness and security of the API Docker image by upgrading the Node.js runtime to version 20 and implementing a more secure and reproducible installation method. By leveraging NodeSource with GPG key verification and version pinning, the changes mitigate risks associated with untrusted package sources and ensure consistent build outcomes. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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.
Code Review
The pull request modifies the api/Dockerfile to enhance the Node.js installation process. It introduces specific arguments for NODE_MAJOR, NODE_PACKAGE_VERSION, and NODESOURCE_KEY_FPR to control the Node.js version. The changes involve setting up the official NodeSource APT repository by installing ca-certificates, curl, and gnupg, downloading and verifying the NodeSource GPG key, and then installing a precise version of Node.js from this repository, rather than relying on the default distribution's package.
Agree |
| Thank you for the advice. I've upgraded Node.js to 22. |
Important
Fixes #<issue number>.Summary
Screenshots
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods