Skip to content

fix(web): catch clipboard copy on security-scanner - #986

Merged
riderx merged 3 commits into
mainfrom
cursor/fix-security-scanner-clipboard-a5a8
Aug 24, 2026
Merged

fix(web): catch clipboard copy on security-scanner#986
riderx merged 3 commits into
mainfrom
cursor/fix-security-scanner-clipboard-a5a8

Conversation

@riderx

@riderx riderx commented Aug 23, 2026

Copy link
Copy Markdown
Member

Problem

Capgo-owned marketing page apps/web/src/pages/security-scanner.astro (live: https://capgo.app/security-scanner/) used an unguarded inline handler:

<button onclick="navigator.clipboard.writeText('bunx @capgo/capgo-sec scan')" ...>

navigator.clipboard.writeText returns a Promise and rejects with NotAllowedError / SecurityError when permission is denied (non-secure contexts, blocked permissions, some mobile browsers). Inline onclick= 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

  • Remove the raw onclick="navigator.clipboard.writeText(...)".
  • Match sibling pages (skills.astro, tools/ios-udid-finder/result.astro): click listener, navigator.clipboard?.writeText feature detect, try/catch, document.execCommand('copy') fallback with try/finally cleanup.
  • Keep the copy icon in place. Brief Copied / Copy failed feedback goes to an aria-live="polite" status under the command, so the button width does not shift.
  • Scanned apps/web/src/pages for other raw onclick="navigator.clipboard..." — this was the only hit.

Out of scope

Visual

Local headless check on http://localhost:3000/security-scanner/: no onclick, SVG stays after click, status announces Copied, clipboard gets bunx @capgo/capgo-sec scan, forced NotAllowedError does not become an uncaught pageerror.

Before:

Security scanner CLI copy button before click

After click (Copied under the command, icon unchanged):

Security scanner CLI copy button with Copied status

Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

Summary by CodeRabbit

  • Enhancements
    • Improved the scanner command copy control with clearer success and failure feedback.
    • Added compatibility support for browsers without the modern Clipboard API.
    • Added live status updates that reset automatically after copying.

Unguarded writeText rejects with NotAllowedError/SecurityError
and inline onclick cannot catch that promise.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f47d401a-cf37-429f-9899-a25fd6da6fd7

📥 Commits

Reviewing files that changed from the base of the PR and between 2c07a37 and d4f1b76.

📒 Files selected for processing (1)
  • apps/web/src/pages/security-scanner.astro
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

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.


📝 Walkthrough

Walkthrough

The 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.

Changes

Scanner command copy flow

Layer / File(s) Summary
Copy control data contract
apps/web/src/pages/security-scanner.astro
The copy button stores the scanner command in data-scanner-copy and removes its inline handler.
Clipboard handling and feedback
apps/web/src/pages/security-scanner.astro
Client-side handling uses the Clipboard API or a textarea fallback. It cleans up temporary elements, updates the ARIA-live status, and resets the message after 1.6 seconds.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to d4f1b

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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the web security scanner clipboard-copy fix, which matches the main change in the pull request.

Comment @coderabbitai help to get the list of available commands.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@riderx
riderx marked this pull request as ready for review August 23, 2026 23:16

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/web/src/pages/security-scanner.astro Outdated
Comment thread apps/web/src/pages/security-scanner.astro Outdated
Comment thread apps/web/src/pages/security-scanner.astro Outdated
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>
@sonarqubecloud

Copy link
Copy Markdown

@riderx
riderx merged commit f5c0c38 into main Aug 24, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants