[Security] Harden downloadFile and downloadGitHubRelease#7795
[Security] Harden downloadFile and downloadGitHubRelease#7795gonzaloriestra wants to merge 1 commit into
Conversation
Hardened the `downloadFile` utility in `packages/cli-kit` to validate the HTTP response status code before processing the body. This prevents failed downloads from saving error pages as valid files. Refactored `downloadGitHubRelease` to use `downloadFile`, enabling streaming downloads for GitHub release assets. This mitigates memory exhaustion (DoS) risks associated with downloading large releases.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR hardens the file download logic in the CLI.
downloadFilestatus validation: Added a check forres.okin thedownloadFileutility. Previously, it would proceed to pipe the response body even if the request failed (e.g., 404 or 500), potentially saving an HTML error page to the target path.downloadGitHubReleaseto use thedownloadFileutility. This switches the download mechanism fromresponse.arrayBuffer()to a streaming pipeline, which is more memory-efficient and prevents potential Denial of Service (DoS) when downloading large assets.Tests have been updated to verify these changes.
PR created automatically by Jules for task 16758916623768002703 started by @gonzaloriestra