Validate slide PDF downloads before writing - #51142
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
SummaryExcellent work on addressing the security vulnerability! This PR hardens PDF download handling in What's Aligned✅ Focused scope — The PR isolates a single security concern: validating slide PDF downloads Ready for ReviewThis PR is in draft and appears ready for transition to ready-for-review when the author determines implementation is complete. The code follows the project's patterns, includes defensive documentation (LGTM comment), and integrates well with existing PDF handling logic.
|
There was a problem hiding this comment.
Pull request overview
Hardens slide PDF downloads before writing them to disk.
Changes:
- Validates trusted URL components, response metadata, size, and PDF signatures.
- Adds focused validation tests.
Show a summary per file
| File | Description |
|---|---|
scripts/ensure-docs-slide-pdf.js |
Adds download and PDF validation. |
scripts/ensure-docs-slide-pdf.test.js |
Tests validation and URL hardening. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
| } | ||
| validateSlideDeckResponse(response); | ||
|
|
||
| const downloadedBytes = Buffer.from(await response.arrayBuffer()); |
|
|
||
| assertThrowsMatching(() => buildSlideDeckUrl("github/gh-aw", "main"), /Unsafe git ref/, "rejects non-SHA git ref"); | ||
|
|
||
| console.log("All ensure-docs-slide-pdf tests passed."); |
|
🎉 This pull request is included in a new release. Release: |
Code scanning flagged
scripts/ensure-docs-slide-pdf.jsfor writing network-derived data to disk without sufficient validation. The script now constrains the download source and validates response metadata and PDF bytes before writing.Download source hardening
owner/repoand commit SHA components.https://media.githubusercontent.com.Response and content validation
content-lengthvalues.%PDF-signature before returning bytes for file write.Focused coverage