Repository navigation
security: move inline event handlers to CSP-safe bindings - #52
Merged
Merged
Conversation
Cacti's Content-Security-Policy script-src-attr directive blocks inline event-handler attributes. This converts slowlog's remaining inline handlers: - The charts, summary and details filter views (slowlog.php) drop their inline onClick/onChange on the Go/Clear buttons, filter selects, time-shift icons and timespan select; each control is bound in its own view's ready block to the same applyFilter/clearFilter/applyChartsFilter/applyGraphTimespan/ timeshift functions it already called. Go submit buttons rely on the existing form-submit binding; Clear buttons are bound form-scoped (they share a class, not an id). - The confirmation Cancel button switches from onClick='window.location.assign' to the cactiReturnTo class + data-url. - The per-field clear glyph (slowlog_details_filter_clear_glyph in includes/slowlog_functions.php) drops its inline onclick for a slowlogClearFilter class + data-url, bound by a delegated handler. includes/slowlog_functions.php is measured; a new SlowlogClearGlyphTest covers the changed glyph line. slowlog.php is already in the patch-coverage allowlist. No i18n calls changed, so cacti.pot is untouched. Cacti 1.2.31+ binds the cactiReturnTo class automatically; the README documents a one-time applySkin() snippet for earlier releases.
TheWitness
requested review from
bmfmancini,
browniebraun and
xmacan
and
a balanced review from Copilot
October 7, 2026 22:32
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Duplicate chart-form submit bindings trigger two page-load requests per submission.
1 open finding
What changed in this PR
Updates slowlog’s UI event bindings to comply with Cacti’s Content Security Policy.
Changes:
- Replaces inline handlers with JavaScript bindings and data attributes.
- Adds clear-filter markup coverage.
- Documents compatibility steps for older Cacti releases.
| File | Description |
|---|---|
| tests/Unit/SlowlogClearGlyphTest.php | Tests CSP-safe clear-filter markup. |
| slowlog.php | Updates filter, navigation, and Cancel bindings. |
| README.md | Documents older-version Cancel support. |
| includes/slowlog_functions.php | Removes the clear glyph’s inline handler. |
| CHANGELOG.md | Records 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.
bmfmancini
previously approved these changes
Oct 8, 2026
Removed event handler for charts filter submission. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
bmfmancini
approved these changes
Oct 8, 2026
browniebraun
approved these changes
Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Removes slowlog's remaining inline event-handler attributes so pages comply with Cacti's Content-Security-Policy
script-src-attrdirective. Part of the fleet-wide CSP inline-handler cleanup.Changes
#logid/#mmethod/#table/#rows/#myuser/#host), time-shift icons and the predefined-timespan select drop their inlineonClick/onChange. Each is bound in its own view's ready block to the sameapplyFilter/clearFilter/applyChartsFilter/applyGraphTimespan/timeshiftGraphFilterLeft/Rightfunctions it already called.Gosubmit buttons use the existing form-submit binding;Clearbuttons (which share a class, not an id) are bound form-scoped.onClick='window.location.assign(...)'→cactiReturnToclass +data-url.slowlog_details_filter_clear_glyphin includes/slowlog_functions.php) — inlineonclick→slowlogClearFilterclass +data-url, bound by a delegated handler.Gate / tests
includes/slowlog_functions.phpis measured; a new tests/Unit/SlowlogClearGlyphTest.php covers the changed glyph line.slowlog.phpis already in the patch-coverage allowlist. No__()/__esc()calls changed, socheck-i18n-pot.phppasses without regeneratingcacti.pot.Compatibility
Cacti 1.2.31+ binds the
cactiReturnToclass automatically. The README documents a one-timeapplySkin()snippet for earlier releases. No shim is baked into core or the plugin.