fix(web): catch clipboard copy on security-scanner - #986
Conversation
Unguarded writeText rejects with NotAllowedError/SecurityError and inline onclick cannot catch that promise. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthroughThe scanner command copy control now uses a data attribute and delegated client-side handling. It supports the Clipboard API and a textarea fallback. An ARIA-live status reports success or failure and resets after 1.6 seconds. ChangesScanner command copy flow
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change makes clipboard copying fail safely and provides accessible status feedback without shifting the button layout. A final visual check should confirm keyboard focus remains visible in both states, but no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Avoid layout shift from replacing the SVG, announce via aria-live, and always remove the execCommand helper. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
|



Problem
Capgo-owned marketing page
apps/web/src/pages/security-scanner.astro(live: https://capgo.app/security-scanner/) used an unguarded inline handler:navigator.clipboard.writeTextreturns a Promise and rejects withNotAllowedError/SecurityErrorwhen permission is denied (non-secure contexts, blocked permissions, some mobile browsers). Inlineonclick=does not catch that rejection, so the page throws an uncaught promise / DOMException.Related PostHog SecurityError context on Landing Capgo (project 72308), even though this fingerprint is localStorage on
/:https://eu.posthog.com/project/72308/error_tracking/019eda5c-7246-71c0-8d7e-8d36b3bbc1cb
Fix
onclick="navigator.clipboard.writeText(...)".skills.astro,tools/ios-udid-finder/result.astro): click listener,navigator.clipboard?.writeTextfeature detect,try/catch,document.execCommand('copy')fallback withtry/finallycleanup.aria-live="polite"status under the command, so the button width does not shift.apps/web/src/pagesfor other rawonclick="navigator.clipboard..."— this was the only hit.Out of scope
Visual
Local headless check on
http://localhost:3000/security-scanner/: noonclick, SVG stays after click, status announces Copied, clipboard getsbunx @capgo/capgo-sec scan, forcedNotAllowedErrordoes not become an uncaught pageerror.Before:
After click (Copied under the command, icon unchanged):
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit