Skip to content

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

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

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

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Summary

Removes the inline onChange event handlers from the WMI Accounts and Queries filters so the pages no longer violate Cacti's Content-Security-Policy script-src-attr directive (continuing the CSP cleanup across the plugin fleet).

Changes

  • wmi_accounts.php, wmi_queries.php — each rows selector had inline onChange='applyFilter()'. Bound them in each page's existing $(function(){...}) ready block (alongside the #refresh/#clear/form-submit bindings already there).
  • Regenerated locales/po/cacti.pot for the shifted source line references (msgid set unchanged).

Both files are already in the patch-coverage gate's allowlist (web UI entry points). The cactiReturnTo() cancel buttons are left inline — shared Cacti-core pattern, handled separately.

Deferred

setup.php still has one inline onClick on the account edit dialog's Cancel button ($("#cdialog").dialog("close")); it lives in a coverage-measured file, so it's deferred to a follow-up that can add the needed coverage.

The WMI Accounts and Queries filter pages each carried an inline
onChange='applyFilter()' attribute on their rows selector. Under Cacti's
Content-Security-Policy these trip the script-src-attr directive (inline
event handlers). Bind the selects in each page's existing
$(function(){...}) ready block alongside the Refresh/Clear/submit bindings
already there. Regenerated locales/po/cacti.pot for the shifted source
line references.

wmi_accounts.php and wmi_queries.php are already in the patch-coverage
gate's allowlist. The cactiReturnTo() cancel buttons are left inline
(shared Cacti-core pattern, tracked separately).

Copilot AI 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.

🟡 Changes recommended

The CSP-sensitive behavior lacks regression coverage in both patch-coverage-excluded entry points.

2 open findings
What changed in this PR

Moves filter event handlers into nonce-protected ready blocks to improve CSP compliance.

Changes:

  • Removes inline onChange handlers from both row selectors.
  • Adds equivalent jQuery change bindings.
  • Updates changelog and gettext metadata.
File Description
wmi_accounts.php Moves the rows handler into the ready block.
wmi_queries.php Moves the rows handler into the ready block.
locales/​po/​cacti.pot Refreshes POT creation metadata.
CHANGELOG.md Documents the CSP cleanup.

🧠 Review effort: Balanced


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

Comment thread wmi_accounts.php
Comment thread wmi_queries.php
TheWitness and others added 2 commits October 7, 2026 17:11
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.
Assert the WMI Accounts and Queries filters carry no inline onChange handler on the rows select and bind the change event from the ready block. Both files are exempt from the patch-coverage gate, so this source-level test is what catches a reintroduced inline handler.
@TheWitness
TheWitness merged commit 8f36f52 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.

4 participants