Skip to content

Add a Scanner tab and dashboard widget backed by tuwebcumple.es - #20

Merged
davidperezgar merged 2 commits into
mainfrom
feature/scanner-tab
Nov 4, 2026
Merged

davidperezgar merged 2 commits into
mainfrom
feature/scanner-tab

Conversation

@davidperezgar

Copy link
Copy Markdown
Contributor

Summary

Adds a Scanner tab to the FrontConsent settings page and a dashboard widget, both showing the site's cookie-compliance result from the tuwebcumple.es scan API.

  • Scanner tab (right after Settings): an administrator clicks "Scan my site"; the server sends home_url() to POST https://tuwebcumple.es/api/v1/scans, then the browser polls (every poll_after_seconds, max 40 polls) through admin-ajax until the scan finishes. Shows grade, score, headline, fail/warning/pass counts, each requirement with icon + text label, and a link to the full result.
  • Dashboard widget (manage_options only): last grade, headline and counts, with a link to the tab. Polls too if a scan is in progress.
  • New class includes/Admin/Scanner.php, registered in Plugin_Main; assets assets/admin/scanner.js / scanner.css (vanilla JS, no jQuery), added to bin/build-assets.js.

Protection and privacy

  • Scans start only on an administrator's click; both AJAX endpoints check manage_options and a nonce.
  • The status endpoint only asks about the scan this site started (uuid from the stored option), never one sent by the browser.
  • 10-minute cooldown per site (transient), on top of the API's own limits (per-IP, global daily cap, 60-minute reuse per URL). The cooldown only starts on a successful request.
  • API responses are whitelisted and sanitized before being stored in the non-autoloaded frontconsent_scan_result option; all output is escaped.
  • readme.txt "External services" documents tuwebcumple.es (the only server-side request, and only on click). Filters: frontconsent_scanner_api_url, frontconsent_scanner_site_url.

Depends on closemarketing/app-tuwebcumple#18 (public scan API), which must be deployed before releasing this.

Notes

  • Result texts (headline, requirement labels) come from tuwebcumple.es in Spanish; the plugin's own UI strings are English and translatable.
  • A site on localhost gets the API's 422 ("No podemos analizar esa dirección…"), shown as-is.

Tests

  • tests/Unit/ScannerTest.php (12 tests, API mocked via pre_http_request): tab position, start/store/cooldown, no API call while pending or within cooldown, status polls only the stored uuid, 422/429 handling, capability check, output escaping, compact widget output, widget registration for administrators only.
  • Full suite 120/120, composer lint and composer phpstan clean.
  • Checked manually in Studio: tab with a seeded result, cooldown message on click, dashboard widget.

🤖 Generated with Claude Code

The Scanner tab sends the site's home URL to the tuwebcumple.es scan API
when an administrator clicks "Scan my site", follows the scan until it
finishes and lists the grade, headline and per-requirement results. A
dashboard widget shows the last grade with a link to the tab.

Requests are made server-side through admin-ajax (manage_options and a
nonce); the status endpoint only asks about the scan this site started.
A 10-minute cooldown per site sits on top of the API's own rate limits.
The result is sanitized and stored in the frontconsent_scan_result
option. The external service is documented in readme.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T22:35:33.136469Z
We couldn’t complete this review. Comment @codex review to try again.
31940ee PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

The status message kept "Analyzing your site…" after the pending result
(which shows the same line with a spinner) was rendered, so it appeared
twice. Clear the message whenever a result is rendered, and cover the
start and error paths of scanner.js with node tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davidperezgar
davidperezgar merged commit 06fdc1f into main Nov 4, 2026
6 checks passed
@davidperezgar
davidperezgar deleted the feature/scanner-tab branch November 4, 2026 19:44
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.

1 participant