Skip to content

Restrict analytics tracking and harden settings and releases - #58

Open
jdevalk wants to merge 4 commits into
simpleanalytics:mainfrom
jdevalk:codex/security-hardening
Open

jdevalk wants to merge 4 commits into
simpleanalytics:mainfrom
jdevalk:codex/security-hardening

Conversation

@jdevalk

@jdevalk jdevalk commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Analytics scripts could load on login and admin pages, and administrators without unfiltered_html could choose an arbitrary script origin through Custom Domain. This change limits tracking to front-end pages and requires an authorized save before a custom domain can serve scripts.

  • Apply tracking exclusions to automated events and always exclude multisite super admins, including those without a role on the current site.
  • Validate custom domains as hostnames and bind approval to the saved value and site; use the same approved domain for analytics, events, and noscript requests.
  • Exclude development files from WordPress.org packages and guard PHP files against direct access.
  • Make releases manually triggered on main, pin release/test actions to commit SHAs, pass shell inputs through environment variables, and restrict default token permissions while preserving the release-app integration.
  • Handle array-valued tab parameters, escape tab links and labels, and remove the external admin font request.

Upgrade note: Existing custom domains fall back to the default CDN until an administrator with unfiltered_html saves them again.

Validation: pnpm build and pnpm tests pass on the rebased branch: 28 tests, comprising 22 Chromium browser tests and six PHP regression scripts. Workflow YAML, action pins, permissions, shell interpolation, and git diff --check also pass.

Update

Changes pushed on top of this PR:

  • Existing custom domains keep working. The approval hash is removed. It disabled every existing custom domain on upgrade, after a salt rotation, and when the domain is set with WP-CLI. The unfiltered_html check on save stays and still stops multisite site administrators from changing the script origin. The upgrade note above no longer applies.
  • Warnings beside the field. A rejected domain, a user without permission trying to change it, and a saved value that can't be used are now explained inside the settings page. WordPress's own notices are hidden by the page's shadow root. Pasted URLs such as https://Stats.Example.com/ are saved as stats.example.com.
  • Network administrators are an option. Instead of always being excluded, multisite sites get a "Network administrator (Super Admin)" choice among the excluded roles, so existing sites keep collecting their visits. With no roles selected, every logged-in user is still excluded.
  • The weekly release stays. The Monday run tests new WordPress versions and releases automatically. The review suggestion on .github/workflows/release.yml restores its schedule and keeps the pinned actions, permissions and concurrency from this PR.
  • Merged current main.

Validation: all 30 browser and WordPress regression tests pass locally on WordPress 7.1.4 with PHP 8.5, plus the regression scripts on multisite. CI covers MySQL and PHP 7.4.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 9cefb91e-dedd-4678-a52c-fe8d3c815d03
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

jdevalk commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

CI update for commit 8ef3ad2: all ten WordPress/PHP matrix jobs passed in the E2E test run.

The only failed check is pull-request / sdlc-label. Its “Ensure SDLC labels” step fails when updating a repository label with Resource not accessible by integration. This is a workflow token-permission failure, not a failing plugin test. Since this PR comes from a fork, a repository maintainer may need to review how the labeling workflow handles fork PRs; no repository permissions or labeling workflows have been changed in this PR.

… optional

Custom domains saved before this release, set with WP-CLI, or saved before a
salt rotation now keep loading scripts. Changing the domain still requires
unfiltered_html, which is the check that stops site administrators on
multisite from choosing a script origin, so the approval hash is removed.
Pasted URLs are reduced to their hostname, and a rejected change or an
unusable saved value is explained beside the field, where the settings page
shows it.

Network administrators are excluded only when "Network administrator (Super
Admin)" is selected among the roles, so existing sites keep collecting their
visits. With no roles selected, every logged-in user stays excluded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
schedule:
- cron: "0 8 * * 1" # At 08:00 on Monday.
workflow_dispatch: # Allows manual triggering
workflow_dispatch: # Releases require an explicit manual trigger on main.

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.

Keep the weekly run: every Monday it tests new WordPress versions and releases when anything changed. This restores only the trigger and keeps this PR's pinned actions, permissions and concurrency.

Suggested change
workflow_dispatch: # Releases require an explicit manual trigger on main.
schedule:
- cron: "0 8 * * 1" # At 08:00 on Monday: test new WordPress versions and release when anything changed.
workflow_dispatch: # Allows manual triggering

@simpleanalytics-agent simpleanalytics-agent added the change: needs review Significant or emergency change affecting security, data protection, or stability label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change: needs review Significant or emergency change affecting security, data protection, or stability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants