Skip to content

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

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 graph-export 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

  • gexport.php — the Rows (#rows) and refresh-interval (#refresh) selects had inline onChange='applyFilter()'. Removed them and bound both via .change() in the existing ready block (the refresh select was previously bound via .click(), which does not reliably fire on a <select>, and the rows select was unbound).
  • Regenerated locales/po/cacti.pot for the shifted source line references (msgid set unchanged).

gexport.php is already in the patch-coverage gate's allowlist (web UI entry point). The cactiReturnTo() cancel buttons on confirmation pages are left inline — shared Cacti-core pattern, handled separately.

The graph-export filter's Rows and refresh-interval 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 bind both selects via change in the existing ready block (the
refresh select was previously bound via click, which does not reliably fire
on a select, and the rows select was unbound). Regenerated
locales/po/cacti.pot for the shifted source line references.

gexport.php is 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

Choose a reason for hiding this comment

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

🟢 Approval recommended

The event bindings preserve filter behavior while eliminating the reported CSP violation.

0 open findings

What changed in this PR

Removes CSP-incompatible inline filter handlers and binds select changes through the existing jQuery ready block.

Changes:

  • Bind Rows and Refresh selects using .change().
  • Remove inline onChange attributes.
  • Update changelog and gettext metadata.
File Description
gexport.php Moves filter event handling into nonce-protected JavaScript.
locales/​po/​cacti.pot Regenerates translation template metadata.
CHANGELOG.md Documents the CSP fix.

🧠 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 97a8620 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