fix(review): bound screenshot height probe - #3959
Conversation
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-07 07:57:01 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3959 +/- ##
=======================================
Coverage 93.66% 93.66%
=======================================
Files 372 372
Lines 34856 34862 +6
Branches 12743 12744 +1
=======================================
+ Hits 32649 32655 +6
Misses 1588 1588
Partials 619 619
🚀 New features to boost your workflow:
|
Motivation
page.evaluate()in the page's own JS realm without a timeout, which a hostile page can hang and thus cause the public screenshot route to block or exhaust rendering resources.Description
SCREENSHOT_HEIGHT_PROBE_TIMEOUT_MSand use it to time-bound the height probe before rasterization viaPromise.racearoundpage.evaluate().render_screenshot_height_probe_timeout) and returningnullto avoid reachingpage.screenshot().SCREENSHOT_TIMEOUT_MS) and the post-capture PNG dimension/byte checks (readPngDimensions) so Chromium-rasterized output continues to be the ultimate enforcement point.page.evaluate()and asserts the probe times out, no rasterization is attempted, and the browser is closed.Testing
npx vitest run test/unit/visual-shot.test.ts, and the tests passed locally.npx vitest run test/unit/visual-shot.test.ts -t "height probe|screenshot rasterization|bounded review|attacker-controlled", which passed and emitted the newrender_screenshot_height_probe_timeoutlog event.npm run typecheckandgit diff --check, both of which succeeded locally.npm run test:coveragedue to a local dependency tree resolvingjs-tokens@4.0.0whileast-v8-to-istanbulexpects^10.0.0, andnpm audit --audit-level=moderatereturned a403from the registry; these are infra/dependency issues unrelated to the source change itself.Codex Task