diff --git a/CHANGELOG.md b/CHANGELOG.md index e81bad8..ad3dba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Jamf Plugin for GLPI Changelog +## [Unreleased] + +### Changed + +- Make the plugin compatible with the Content Security Policy + ## [3.2.4] - 2026-11-05 ### Fixed diff --git a/inc/computer.class.php b/inc/computer.class.php index 0224568..6ce6ab6 100644 --- a/inc/computer.class.php +++ b/inc/computer.class.php @@ -74,9 +74,12 @@ public static function showForItem(array $params) $match = $jamf_item->fields; $match = array_merge($match, $jamf_item->getJamfDeviceData()); + $sync_button_id = 'jamf_sync_' . $item->getID(); $js = ''; if ($item->canUpdate()) { $ajax_url = $CFG_GLPI['root_doc'] . '/plugins/jamf/ajax/sync.php'; + $itemtype = $item::getType(); + $items_id = $item->getID(); $js = << syncDevice("{$itemtype}", {$items_id})); JAVASCRIPT; } @@ -135,8 +139,8 @@ function syncDevice(itemtype, items_id) { 'url' => self::getJamfDeviceURL($match['jamf_items_id']), ], 'sync' => [ - 'caption' => _x('action', 'Sync now', 'jamf'), - 'on_click' => sprintf('syncDevice("%s", %s); return false;', $item::getType(), $item->getID()), + 'caption' => _x('action', 'Sync now', 'jamf'), + 'id' => $sync_button_id, ], ], 'extra_js' => $js, diff --git a/inc/mobiledevice.class.php b/inc/mobiledevice.class.php index de980f9..929a1c7 100644 --- a/inc/mobiledevice.class.php +++ b/inc/mobiledevice.class.php @@ -287,8 +287,11 @@ public static function showForItem(array $params) $match = array_merge($match, $jamf_item->getJamfDeviceData()); $js = ''; + $sync_button_id = 'jamf_sync_' . $item->getID(); if ($item->canUpdate()) { $ajax_url = $CFG_GLPI['root_doc'] . '/plugins/jamf/ajax/sync.php'; + $itemtype = $item::getType(); + $items_id = $item->getID(); $js = << syncDevice("{$itemtype}", {$items_id})); JAVASCRIPT; } @@ -355,8 +359,8 @@ function syncDevice(itemtype, items_id) { 'url' => self::getJamfDeviceURL($match['jamf_items_id']), ], 'sync' => [ - 'caption' => _x('action', 'Sync now', 'jamf'), - 'on_click' => sprintf('syncDevice("%s", %d); return false;', $item::getType(), $item->getID()), + 'caption' => _x('action', 'Sync now', 'jamf'), + 'id' => $sync_button_id, ], ], 'extra_js' => $js, @@ -401,9 +405,11 @@ function syncDevice(itemtype, items_id) { ], 'lost_location' => [ 'caption' => _x('field', 'GPS', 'jamf'), - 'value' => Html::link(sprintf('%s, %s', $lat, $long), sprintf('https://www.google.com/maps/place/%s,%s', $lat, $long), [ - 'display' => false, - ]), + 'value' => sprintf( + '%s', + htmlescape(sprintf('https://www.google.com/maps/place/%s,%s', $lat, $long)), + htmlescape(sprintf('%s, %s', $lat, $long)), + ), ], 'lost_location_altitude' => [ 'caption' => _x('field', 'Altitude', 'jamf'), diff --git a/setup.php b/setup.php index 65a03dc..b12ab63 100644 --- a/setup.php +++ b/setup.php @@ -89,6 +89,7 @@ function plugin_version_jamf() 'author' => "Teclib' & Curtis Conard", 'license' => 'GPLv2', 'homepage' => 'https://github.com/pluginsGLPI/jamf', + 'csp_compliant' => true, 'requirements' => [ 'glpi' => [ 'min' => PLUGIN_JAMF_MIN_GLPI, diff --git a/templates/import.html.twig b/templates/import.html.twig index 8b06298..c2562fc 100644 --- a/templates/import.html.twig +++ b/templates/import.html.twig @@ -80,9 +80,9 @@
- - - + + +
diff --git a/templates/inventory_info.html.twig b/templates/inventory_info.html.twig index 5396056..0ef03b1 100644 --- a/templates/inventory_info.html.twig +++ b/templates/inventory_info.html.twig @@ -43,7 +43,7 @@ {% if button.url %} {{ button.caption }} {% else %} - + {% endif %} {% endfor %} diff --git a/templates/mdm_commands.html.twig b/templates/mdm_commands.html.twig index b858553..8ac9baa 100644 --- a/templates/mdm_commands.html.twig +++ b/templates/mdm_commands.html.twig @@ -38,7 +38,7 @@
{% for command, command_params in commands %} -
{{ command_params.name }} @@ -103,5 +103,8 @@ itemtype: "{{ jamf_itemtype }}", items_id: {{ jamf_items_id }}, }); + $('[data-jamf-mdm-command]').on('click', (e) => { + jamfPlugin.onMDMCommandButtonClick(e.currentTarget.dataset.jamfMdmCommand, e); + }); }); diff --git a/templates/merge.html.twig b/templates/merge.html.twig index ebc63db..08daa42 100644 --- a/templates/merge.html.twig +++ b/templates/merge.html.twig @@ -82,7 +82,7 @@

- +