Skip to content

feat: make plugin CSP compliant - #255

Merged
Lainow merged 1 commit into
11.0/bugfixesfrom
csp-compliance
Nov 20, 2026
Merged

Lainow merged 1 commit into
11.0/bugfixesfrom
csp-compliance

Conversation

@Rom1-B

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

Copy link
Copy Markdown
Contributor

Description

The plugin now declares csp_compliant and no longer relies on inline event handlers, so it keeps working when GLPI sends its Content Security Policy.

Converted patterns:

  • templates/view.html.twig: fullscreen button onclick="gantt.ext.fullscreen.toggle();" replaced by the data-gantt-fullscreen attribute (category a).
  • templates/view.html.twig: search field oninput="gantt.$doFilter(this.value);" replaced by the data-gantt-filter attribute (category a).
  • public/js/gantt-helper.js: two delegated listeners bound once at file load, calling the same functions with the same arguments.
  • setup.php: 'csp_compliant' => true added to plugin_version_gantt().

No <script> tag was printed from PHP or created from JavaScript: the only inline script is literal Twig text and receives the nonce automatically.

No behaviour change.

Blocked by

Manual test checklist

Open a project with the Gantt tab (Project item, Gantt tab) and keep the browser console open. CSP violations are reported there as Refused to execute inline event handler or Refused to execute inline script.

  • Click the fullscreen button (icon at the top right of the Gantt controls): the Gantt enters and leaves fullscreen mode.
  • Type in the "by name" search field with the Find option selected: matching tasks are highlighted and the view refreshes about 500 ms after typing stops.
  • Type in the same field with the Filter option selected: only matching tasks are displayed.
  • No CSP error appears in the console.

@Rom1-B
Rom1-B marked this pull request as ready for review November 19, 2026 10:05
@Rom1-B
Rom1-B requested review from a team, Herafia, Lainow and jdurand-teclib and removed request for a team November 19, 2026 10:05
@Lainow
Lainow merged commit 287e845 into 11.0/bugfixes Nov 20, 2026
7 checks passed
@Lainow
Lainow deleted the csp-compliance branch November 20, 2026 13:48
@glpi-project

glpi-project Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Backport-action backported this pull request in workflow run 44747507646.

Target Status
main ⚠️ Drafted with conflicts #258

Rom1-B added a commit that referenced this pull request Nov 24, 2026
jdurand-teclib pushed a commit that referenced this pull request Nov 25, 2026
Forward-port of #255 to `main`.

## Description

The plugin now declares `csp_compliant` and no longer relies on inline
event handlers, so it keeps working when GLPI sends its Content Security
Policy.

Converted patterns:

- `templates/view.html.twig`: fullscreen button
`onclick="gantt.ext.fullscreen.toggle();"` replaced by the
`data-gantt-fullscreen` attribute (category a).
- `templates/view.html.twig`: search field
`oninput="gantt.$doFilter(this.value);"` replaced by the
`data-gantt-filter` attribute (category a).
- `public/js/gantt-helper.js`: two delegated listeners bound once at
file load, calling the same functions with the same arguments.
- `setup.php`: `'csp_compliant' => true` added to
`plugin_version_gantt()`.

No `<script>` tag was printed from PHP or created from JavaScript: the
only inline script is literal Twig text and receives the nonce
automatically.

No behaviour change.

## Blocked by

- glpi-project/glpi#26020 (CSP) and its 11.0 / 12.0 backports: the
minimum GLPI version (`PLUGIN_GANTT_MIN_GLPI_VERSION`, currently 11.0.0)
must be bumped to the first CSP-enabled release before merging.

## Manual test checklist

Open a project with the Gantt tab (Project item, Gantt tab) and keep the
browser console open. CSP violations are reported there as `Refused to
execute inline event handler` or `Refused to execute inline script`.

- Click the fullscreen button (icon at the top right of the Gantt
controls): the Gantt enters and leaves fullscreen mode.
- Type in the "by name" search field with the Find option selected:
matching tasks are highlighted and the view refreshes about 500 ms after
typing stops.
- Type in the same field with the Filter option selected: only matching
tasks are displayed.
- No CSP error appears in the console.

Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
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