Skip to content

security: move filter inline onChange handlers into ready() for CSP - #24

Merged
TheWitness merged 2 commits into
developfrom
fix/csp-filter-inline-handlers
Oct 8, 2026
Merged

TheWitness merged 2 commits into
developfrom
fix/csp-filter-inline-handlers

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Summary

Removes the inline onChange event handlers from the tags filter so the page no longer violates Cacti's Content-Security-Policy script-src-attr directive (continuing the CSP cleanup across the plugin fleet).

Changes

  • tags.php — the Target (#target), Type (#type) and Rows (#rows) selects had inline onChange='applyFilter()'. Removed them and corrected the ready block to bind those selects via .change() (they were previously bound via .click(), which does not reliably fire on a <select> — the inline onChange was what actually drove them).
  • tests/bin/patch-coverage.php — allowlist tags.php (web UI entry point not loaded into the isolated unit process).
  • Regenerated locales/po/cacti.pot for the shifted source line references (msgid set unchanged).

The cactiReturnTo() cancel buttons on confirmation pages are left inline — shared Cacti-core pattern, handled separately.

The tags filter's Target, Type and Rows selects carried inline
onChange='applyFilter()' attributes. Under Cacti's Content-Security-Policy
these trip the script-src-attr directive (inline event handlers). Remove
them and fix the ready block to bind those selects via change (they were
bound via click, which does not reliably fire on a select). Allowlist
tags.php in the patch-coverage gate (web UI entry point, not loaded into
the isolated unit process). Regenerated locales/po/cacti.pot for the
shifted source line references.

The cactiReturnTo() cancel buttons are left inline (shared Cacti-core
pattern, tracked separately).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrowly scoped changes preserve filter behavior, with no blocking issues identified.

0 open findings

What changed in this PR

Updates tag filters to avoid inline event handlers blocked by Cacti’s Content Security Policy.

Changes:

  • Binds filter selects through change events in the ready block.
  • Exempts the web entry point from unmeasured patch coverage.
  • Documents the change and refreshes the translation template timestamp.
File Description
tests/​bin/​patch-coverage.php Allowlists tags.php as an unmeasured web entry point.
tags.php Replaces inline handlers and click bindings with change bindings.
locales/​po/​cacti.pot Updates the template creation timestamp.
CHANGELOG.md Records the filter event-handler change.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The confirmation pages' Cancel buttons used an inline
onClick='cactiReturnTo()' handler, which trips Cacti's Content-Security-Policy
script-src-attr directive. Switch them to the CSP-safe cactiReturnTo CSS
class (class='cactiReturnTo', plus an optional data-url when a target is
passed).

Cacti 1.2.31 and later bind this class automatically. The README documents a
one-time include/layout.js applySkin() snippet for operators still on an
earlier release - no shim is baked into the core or the plugin.
@TheWitness
TheWitness merged commit 4eb0ab4 into develop Oct 8, 2026
3 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.

3 participants