Repository navigation
Backup: warn about known threats before restoring a backup - #53755
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Backup plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Boost plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Search plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Protect plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Videopress plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 9 files. Only the first 5 are listed here.
36 files are newly checked for coverage. Only the first 5 are listed here.
Full summary · PHP report · JS report Coverage check overridden by
Coverage tests to be added later
|
Other sites get threats_unavailable without a request to WordPress.com, so their restore screen works as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A backup's period is when it started, so its "Backup complete" row's rewind id is later than the period. The route now returns every period and the row uses the newest backup at or before its rewind id, like the restore check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ackup rows only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The warning box, "Restore this backup instead", the Known threats (N) toggle and its list, and the checkbox, on the restore screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore to this point waits for the acknowledgement, which the restore screen then starts with. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review: no blockers. Checked
Not tested: the real feature end to end. The server changes are not live. On a real WoA site today, the threats route returns 404, the backups list has no Safe merge path
Small gap (not blocking): if counts exist but the per-backup route returns 403 (no Scan), the details view shows the badge but no warning. The restore screen shows the warning only after the first 409. WoA plans include Scan, so this should be rare. — Terminator |
In the Table layout the title and description share a row, so a badge inside the description started under the description, past the title. The cell now places the badge in the row itself, on a line of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
The list's known-threat counts cover only the newest 100 backups, so the details of an older backup never showed its warning. They now ask about that backup directly, as the restore screen does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
With the threats shown, "Restore … backup instead" sat right under the last line of the list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
The acknowledgement sat below the warning, so the warning and the decision it asks for read as two separate things. It is now the warning's last part, below a rule, as on WordPress.com. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
It is the decision the warning asks for, so it stands out as it does on WordPress.com. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
The minimal "Show threats" button has no background or border, so on the warning's coloured background it didn't look like a button. It's now an outline button labelled like the badge elsewhere, with a chevron, as on WordPress.com. Screen readers hear "Known threats (N), show threats". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
|
@dhasilva I pushed a few changes on top of your review fixes, after testing on a test site with real Scan data. Three of them (the last three) reverse choices you made, so here's the reasoning:
New strings: "Known threats (%d), show threats" and "Known threats (%d), hide threats". "Show threats" and "Hide threats" are no longer used. The backup JS tests pass (1092) and the activity-log tests pass (8). I checked each change on the test site. ScreenshotsA test site with real Scan data, at desktop width. Before is this PR before these commits ( Activity Log
Backup details
Restore screen
The older-backup details fix (eb2b678) has no screenshot, because the test site has fewer than 100 backups. A test covers it. |
Resolve the plugin composer.lock conflicts by taking trunk's and updating the monorepo packages again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
|
@RafaelFunchal The outline toggle in Can you keep
I rendered both versions from this branch to check that it still reads as a button on the warning's background. It does.
The "Invalid date" in the "Restore … backup instead" link is from my test page, which has no site date settings. |
…m the badge With the caution icon and "Known threats (N)", the outline button copied the badge in the backups list and the Activity Log, so the badge looked clickable too. The button now reads "Show threats (N)" or "Hide threats (N)" with its chevron, and its visible text is its accessible name.
|
@CGastrell An update after a few more rounds on the toggle. Where it ended up:
Strings: "Show threats" and "Hide threats" are used again. "Show threats (%d)", "Hide threats (%d)", "Known threats (%d), show threats" and "Known threats (%d), hide threats" are no longer used. Checked on the test site: backup details, restore screen, backups list and Activity Log, including the tooltip on hover. Backup JS tests pass (1092), and the activity-log tests pass (3). WordPress.com (Automattic/wp-calypso#115337) follows the same rule: the toggle is a button where the warning is shown, and the badge, with its tooltip, appears elsewhere. ScreenshotsOn the test site, with real Scan data.
|
The toggle was a button labelled like the badge, so the badge looked like something to click. The warning now shows the "Known threats (N)" badge, which is never a control, and beside it a "Show threats" / "Hide threats" link with a chevron that opens and closes the list. It's a button underneath, styled as a link.
The warning already says how many threats the backup has, so the badge beside the toggle repeated it. The warning keeps just the toggle, as an outline button with a chevron, which reads as a button on the warning's background.
The Activity Log doesn't show the warning beside the badge, so hovering the badge now shows it, as on the legacy WordPress.com backup cards. Screen readers still get it as hidden text in the badge. Adds @testing-library/user-event for the hover test.
# Conflicts: # pnpm-lock.yaml # projects/packages/activity-log/package.json
Re-check at
|
| Point | Status |
|---|---|
CheckboxControl from @wordpress/ui |
✅ Still in place. |
Badge from @wordpress/ui instead of a custom pill |
✅ In both the backups list and the Activity Log. |
| Badges are not interactive |
The @wordpress/ui Tooltip usage guidelines are the reference for items 1–3: "Use tooltips as visual labels only. … Do not use tooltips for descriptions, instructions, disabled reasons, or dynamic status messages." They also note that tooltips are disabled on touch devices.
Findings
-
[blocker] The Activity Log badge is a tooltip trigger again. ActivityEvent.tsx#L81-L94
- It makes the badge something you hover, and the tooltip holds a description. That is what @CGastrell flagged for the toggle, citing @simison.
- Only a mouse can open it. Base UI's
Tooltip.Triggeradds notabIndex, so the<span>trigger can't take focus. In a jsdom check, Tab goes from the element before the badge straight to the one after, and the tooltip never opens. Touch devices don't get it either. - Screen readers still get the hidden sentence, so dropping the tooltip loses nothing they rely on.
- Suggest removing the tooltip and keeping the
VisuallyHiddensentence, as the backups list does. The new@testing-library/user-eventdependency and the hover test can go with it.
-
[suggestion] Two tooltips explain why a button is disabled. One is on "Restore to this point" (backup-detail#L224-L236), the other on "Confirm restore" (restore.tsx#L305-L331).
- These date from Oct 18, and my Oct 19 review missed them.
- On the restore screen,
hintInTooltiphides the visible hint in exactly this case, so on a touch device Confirm is disabled with no reason shown. - Dropping
hintInTooltiplets the existing visiblerole="status"hint carry this reason, like it already does for "Select at least one item to restore."
-
[suggestion] The "Restore … backup instead" link puts a description in a tooltip. known-threats/index.tsx#L277-L306
- Touch users never see "It's the most recent backup with no known security threats."
- The sentence is already in the DOM as hidden text. Showing it as small text under the link, or dropping it, both follow the guidelines.
-
[suggestion] CSS overrides the checkbox's own label style.
.jpb-known-threats__acknowledgement label { font-weight }(style.scss#L20-L30) bolds theCheckboxControllabel from outside the component. I see it matches WordPress.com, but overrides like this tend to get the same design-system review comment as the custom pill did. -
[blocker] The PR conflicts with trunk, so CI hasn't run since Oct 21. The React 19 update (Update the monorepo to use React 19 #53882) conflicts with
activity-log/package.jsonandpnpm-lock.yaml. With no merge ref, only "PR is up to date" and CodeQL ran on the last pushes.- Resolution: keep the three
@testing-library/*devDependencies, take@types/react19.3.0, take trunk's lockfile and runpnpm install. - On a trial merge, the backup JS tests (1092) and activity-log JS tests (3) pass, and
typecheckis clean for both packages.
- Resolution: keep the three
Checked, no change needed
- The Oct 19 blockers (2, 3, 4 and 16) are still fixed. No PHP has changed since Oct 20.
- Older backups' details (eb2b678): the extra request stays off where known threats aren't available, since a disabled query reports
isPending. On WoA, a failed count read falls back to checking the backup itself. - Activity Log layout (97a4f33): the content row wraps, so the badge gets its own line under the title.
- Trunk merge (9abe548):
class-initial-state.phpkeeps both trunk'supgradeand this PR'srestoreUrlTemplate/knownThreatsAvailable. - @CGastrell's gap: counts flagged plus a 403 per-backup read still means no warning in the details. It's rare on WoA plans, so I'd leave it.
Test results at 0f7b5d112b7
- PHP:
packages/backup492 OK,packages/activity-log30 OK. - JS:
packages/backup1092 passed,packages/activity-log3 passed. Same on the trial merge with trunk. - Phan:
packages/backupandpackages/activity-log, 0 issues. No new suppressions or baseline entries. - ESLint on the changed files: 3
use-recommended-componentserrors, all on unchanged lines of files already intools/eslint-excludelist.json.
Verdict
Needs changes before merge: items 1 and 5. Items 2–4 are worth clearing too, before @simison looks again.
Generated by Claude.
A design-system badge isn't interactive, and its tooltip only reached mouse users: the span trigger can't take focus, and touch devices get no tooltips. Screen readers still hear the warning from the hidden text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The design system keeps disabled reasons out of tooltips, and touch devices never show them. Confirm restore's acknowledgement hint is back in the visible status text beside it, like its other hints. Restore to this point keeps its screen reader description; the warning's checkbox right below it already shows why it's off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason sat in a tooltip, which touch devices never show and which the design system reserves for labels. It's now small text under the "Restore … instead" link, which still names it as the link's description. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gn system The rule reached into CheckboxControl's own label to bold it, which the component doesn't offer and the design system's other checkboxes don't do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed fixes for the re-check above, one commit per item:
No strings added or removed. Checked: Not checked: I haven't seen these in a browser. @RafaelFunchal, could you look at the "Restore … instead" link and the new line under it on your test site? It's the one visible layout change. The Boost e2e failure on c74aa2c failed at setup ("Site URL could not be resolved") before any test ran, so it isn't related to this PR. Generated by Claude. |
|
Thanks for reviewing and suggesting improvements to this PR, @dhasilva 🙇♂️ |















Proposed changes
Warns before restoring a backup that WordPress.com knows contains security threats, across the Backup dashboard and the Activity Log.
acknowledge_threats(so WordPress.com keeps exempting it), and every screen behaves exactly as before./restore/<rewindId>):threats_not_acknowledged, HTTP 409), the screen returns to the confirm step with the warning shown.jetpack_activity_log_restore_url_templatefilter, and the Jetpack Cloud restore flow otherwise.Notice, the threats sit in aCollapsible, the badge isBadge, and the acknowledgement is@wordpress/ui'sCheckboxControl. Threat dates and the clean backup's name use the site's own date formats and timezone.POST /jetpack/v4/rewind/to/{rewind_id}sendsacknowledge_threatsto WordPress.com, astrueorfalse, on WoA, and omits it elsewhere. A 409threats_not_acknowledgedcomes back as that error instead of a generic upstream error.GET /jetpack/v4/rewind/backups/{rewind_id}/threatsproxies one backup's known threats. Off WoA, and when the threats aren't available, it returnsthreats_unavailable(404).GET /jetpack/v4/rewind/backups/known-threatsreturns the counts for the newest 100 backups. Withwith_clean_rewind_id, it also finds when the latest clean backup finished, which the warning's link needs. A found answer is kept for a month and a missing one for five minutes.GET /jetpack/v4/activity-log/known-threatsgives the Activity Log the same counts.known_threats_only, which older servers ignore.Screenshots
Local site, desktop 1440px and phone 390px. The site isn't hosted on WordPress.com, so the known-threats routes are faked: the 14/10 backup has three threats, and 15/10 is the newest clean one. Dates follow the site's
d/m/Ysetting.Code coverage
The coverage check fails only on Activity Log JS files this PR doesn't change, such as
ActivityActor.tsxandUpsellCallout.tsx. Adding the package's first Jest setup makes the check count them for the first time. Hence the "Coverage tests to be added later" label; the Activity Log's older components can get tests separately.Related product discussion/links
Part of TSCODE-757.
Does this pull request change what data or activity we track or use?
No. The screen reads threat information WordPress.com already has for the site, and on sites hosted on WordPress.com sends a boolean acknowledgement with the restore request.
Testing instructions
jp test js packages/backup,jp test js packages/activity-log,jp test php packages/backupandjp test php packages/activity-log.known-threatsor/threatsrequest, and the restore request carries noacknowledge_threats.🤖 Generated with Claude Code