Skip to content

security: convert cactiReturnTo cancel buttons to the CSP-safe class - #78

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

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

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Summary

Converts the plugin's confirmation-page Cancel buttons from inline onClick='cactiReturnTo(...)' handlers to the CSP-safe cactiReturnTo CSS class, so the pages no longer trip Cacti's Content-Security-Policy script-src-attr directive. Part of the fleet-wide CSP inline-handler cleanup.

Approach (no shim in core or plugin)

  • Markup switches from onClick='cactiReturnTo(url)' to class='cactiReturnTo' (plus data-url='<url>' when a target URL was passed; the no-arg case falls back to document.referrer, which cactiReturnTo() already does).
  • Existing class='ui-button ...' attributes are merged, not duplicated.
  • Cacti 1.2.31+ binds this class automatically. The README documents a one-time applySkin() snippet for operators on earlier releases. Nothing is baked into core or the plugin.

Changes

  • maint.php — 12 Cancel buttons converted (data-url='maint.php').
  • README.md — new "Cacti compatibility" section.
  • CHANGELOG.md — entry.

maint.php is already in the patch-coverage gate's allowlist; all edits are same-line (no source-line shift), so cacti.pot is unaffected.

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.

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

Two converted Return buttons contain malformed HTML that can affect rendering.

1 open finding
What changed in this PR

Replaces inline Cancel/Return handlers with CSP-safe class bindings and documents compatibility requirements.

Changes:

  • Converts 12 controls to cactiReturnTo class bindings.
  • Documents pre-1.2.31 compatibility.
  • Updates the changelog.
File Description
maint.php Converts inline handlers; two malformed button tags remain.
README.md Adds compatibility instructions.
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.

Comment thread maint.php Outdated
The schedules Return control (line 447) ended '</button' with no closing '>', and the webseer Return control (line 587) carried a stray double '>>' in its opening tag. Both left malformed markup on the no-selection path; normalize them to a well-formed <button ...>Return</button>.

@bmfmancini bmfmancini left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed; cactiReturnTo class moves to the Cancel button correctly. Checks pass.

@TheWitness
TheWitness merged commit dccb2c7 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