Skip to content

feat: make plugin CSP compliant - #532

Draft
Rom1-B wants to merge 1 commit into
11.0/bugfixesfrom
csp-compliance
Draft

Rom1-B wants to merge 1 commit into
11.0/bugfixesfrom
csp-compliance

Conversation

@Rom1-B

@Rom1-B Rom1-B commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

Makes the plugin compatible with the Content Security Policy sent by GLPI 11, 12 and 13, and declares it with 'csp_compliant' => true.
No inline event handler or unnonced inline script remains; behaviour is unchanged.

Converted patterns:

  • inc/history.class.php
    • Inline <script> printed from PHP (form pre-fill of the history reassign buttons) now uses Html::scriptBlock() (pattern d).
    • onclick='full_history.show();' on the "more history" link replaced by an id and a jQuery listener in a Html::scriptBlock() (pattern a).
    • onclick='self.opener.location.href=...; self.close();' on group links in the full history popup replaced by an id and a jQuery listener reading this.href (pattern a).
  • templates/config.html.twig
    • on_change of the "Use the technician's group" dropdown (fields.dropdownArrayField) replaced by an add_data_attributes marker and a delegated jQuery change listener in the existing page script (pattern b).
  • setup.php
    • 'csp_compliant' => true added to plugin_version_escalade().

No change to the JS files in public/js/: they are served as script files and contain no inline handler.

Blocked by: glpi-project/glpi#26020 (CSP in GLPI core) and its 11.0 and 12.0 backports.
PLUGIN_ESCALADE_MIN_GLPI must be bumped to the first CSP-enabled GLPI release before merging, because the csp_compliant declaration and the nonce handling do not exist in older releases.

No JS build needed: no file under js/ or public/ was edited.

Screenshots (if appropriate):

Manual test checklist (keep the browser console open, CSP violations show as "Refused to execute inline event handler" or "Refused to execute inline script"):

  1. Setup > Plugins > Escalation, group assignment tab: change "Use the technician's group" between "No" and "First"/"Last"; the "at creation time" and "at modification time" fields and the group borders must show or hide as before.
  2. Ticket form with an escalation history: click a group reassign button; the ticket form must submit to climb_group.php with the ticket details pre-filled.
  3. Ticket with more than 10 group changes: click the "more history" link under the history; the full history modal opens.
  4. In the full history modal, click a group name; the ticket opener window navigates to the group and the modal window closes.
  5. Console shows no CSP violation on the ticket form, the config page and the full history popup.

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.

1 participant