Repository navigation
Conversation
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.
Make the plugin compatible with the GLPI Content Security Policy by removing inline event handlers and javascript: links.
Behaviour is unchanged: same URLs, same request fields, same confirmation message.
Converted patterns
src/Source_Zone.php: the "Download enabled" toggle was ajavascript:void(0)link with anonclick(categories a and c). It is now abtn-as-linkbutton with adata-carbon-toggle-zoneattribute, and the two existingHtml::scriptBlock()scripts bind a click listener to these buttons.src/Config.php:Html::getConfirmationOnActionScript()(deprecated, category b) is removed. The Twig variables now carry the confirmation message, the action URL and the JSON fields.templates/config.html.twig: the two "Reset impacts" buttons usedata-glpi-confirm,data-glpi-submit-get-linkanddata-glpi-submit-get-link-fieldsinstead ofonclick(category a). The unused{% set reset_args %}lines are removed, as they would shadow the context variable.templates/environmentalimpact-item.html.twig: the foursubmitGetLink()onclickhandlers (usage and embodied "Reset data" and "Calculate data") usedata-glpi-submit-get-linkanddata-glpi-submit-get-link-fields, with the fields built by Twigjson_encode(category a).setup.php:'csp_compliant' => trueadded toplugin_version_carbon().Other hits from the searches are not handlers: the
<script>tags intemplates/**/*.twigare literal template text (nonce added by the template engine), and theHtml::scriptBlock()calls already emit a nonce.Blocked by
data-glpi-confirmanddata-glpi-submit-get-linkattributes do nothing on releases without the backport, so the confirmation would be silently skipped.PLUGIN_CARBON_MIN_GLPI_VERSIONmust be raised to the first CSP-enabled 11.0 release before merging. It is intentionally left at 11.0.0 in this PR, as the release number does not exist yet.Manual test checklist
Keep the browser console open. A CSP violation shows as
Refused to execute inline event handlerorRefused to execute inline script.