diff --git a/ajax/planning.php b/ajax/planning.php index 7232af6..5cc1d4f 100644 --- a/ajax/planning.php +++ b/ajax/planning.php @@ -42,6 +42,8 @@ exit; } +/** @var array $CFG_GLPI */ +/** @var \DBmysql $DB */ global $DB, $CFG_GLPI; if ($_REQUEST["action"] == "add_tickettask") { @@ -151,7 +153,6 @@ echo json_encode($event); } elseif ($_REQUEST["action"] == "update_task") { - $div = PluginTaskdropCalendar::addTask(); $div .= PluginTaskdropCalendar::addReminder(); echo $div; diff --git a/composer.json b/composer.json index a5ca0a4..064ce33 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ "php-parallel-lint/php-parallel-lint": "^1.4", "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^2.1", - "phpstan/phpstan-deprecation-rules": "^2.0" + "phpstan/phpstan-deprecation-rules": "^2.0", + "squizlabs/php_codesniffer": "^3.7" }, "config": { "optimize-autoloader": true, diff --git a/inc/calendar.class.php b/inc/calendar.class.php index ac46c6d..2855266 100644 --- a/inc/calendar.class.php +++ b/inc/calendar.class.php @@ -45,6 +45,7 @@ public static function getTypeName($nb = 0) public static function addTask() { + /** @var \DBmysql $DB */ global $DB; $div = "

" . __('Plan this task') . "

"; @@ -74,8 +75,7 @@ public static function addTask() $rand = rand(); $div .= "
"; - $div .= Toolbox::addslashes_deep(Toolbox::stripTags($row['task_content'])) . "
"; - //$div .= Html::showToolTip($row['task_content'], ['linkid' => 'task_'.$rand, 'display' => false]); + $div .= htmlspecialchars(Toolbox::stripTags($row['task_content'])) . ""; } $query = [ 'FROM' => 'glpi_changetasks', @@ -87,7 +87,7 @@ public static function addTask() ]; foreach ($DB->request($query) as $id => $row) { Toolbox::logInFile('taskndrop2', print_r($row, true)); - $div .= "
" . Toolbox::addslashes_deep(Toolbox::stripTags($row['content'])) . "
"; + $div .= "
" . htmlspecialchars(Toolbox::stripTags($row['content'])) . "
"; } } } else { @@ -115,7 +115,7 @@ public static function addTask() foreach ($DB->request($query) as $id => $row) { $div .= "
"; - $div .= Toolbox::addslashes_deep(Toolbox::stripTags($row['task_content'])) . "
"; + $div .= htmlspecialchars(Toolbox::stripTags($row['task_content'])) . ""; } $query = [ 'FROM' => 'glpi_changetasks', @@ -126,7 +126,7 @@ public static function addTask() ], ]; foreach ($DB->request($query) as $id => $row) { - $div .= "
" . Toolbox::addslashes_deep(Toolbox::stripTags($row['content'])) . "
"; + $div .= "
" . htmlspecialchars(Toolbox::stripTags($row['content'])) . "
"; } } } @@ -135,9 +135,9 @@ public static function addTask() return $div; } - public static function addReminder() { + /** @var \DBmysql $DB */ global $DB; $div = "

" . __('Planning reminder') . "

"; @@ -154,7 +154,7 @@ public static function addReminder() ], ]; foreach ($DB->request($query) as $id => $row) { - $div .= "
" . Toolbox::addslashes_deep(Toolbox::stripTags($row['name'])) . "
"; + $div .= "
" . htmlspecialchars(Toolbox::stripTags($row['name'])) . "
"; } } } @@ -164,6 +164,7 @@ public static function addReminder() public static function listTask($params) { + /** @var array $CFG_GLPI */ global $CFG_GLPI; $options = $params['options']; diff --git a/setup.php b/setup.php index 0d31031..45880cf 100644 --- a/setup.php +++ b/setup.php @@ -67,6 +67,7 @@ function plugin_taskdrop_check_config($verbose = false) function plugin_init_taskdrop() { + /** @var array $PLUGIN_HOOKS */ global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['taskdrop'] = true; diff --git a/tools/codesniffer.sh b/tools/codesniffer.sh new file mode 100755 index 0000000..942d3b2 --- /dev/null +++ b/tools/codesniffer.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +TOOL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" + +# if exist vendor/bin/phpcbf, use it +if [ -f "$TOOL_DIR/../vendor/bin/phpcbf" ]; then + cd "$TOOL_DIR/.." + vendor/bin/phpcbf + exit 0 +fi \ No newline at end of file diff --git a/tools/migrate_accounts.php b/tools/migrate_accounts.php index 6888c42..6d6a126 100644 --- a/tools/migrate_accounts.php +++ b/tools/migrate_accounts.php @@ -188,7 +188,8 @@ function plugin_accounts_AddRoundKey($state, $w, $rnd, $Nb) function plugin_accounts_SubBytes($s, $Nb) { // apply SBox to state S - $Sbox = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + $Sbox = [ + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, @@ -203,7 +204,8 @@ function plugin_accounts_SubBytes($s, $Nb) 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16, + ]; for ($r = 0; $r < 4; $r++) { for ($c = 0; $c < $Nb; $c++) { $s[$r][$c] = $Sbox[$s[$r][$c]]; @@ -267,7 +269,8 @@ function plugin_accounts_MixColumns($s, $Nb) function plugin_accounts_KeyExpansion($key) { // generate Key Schedule from Cipher Key - $Rcon = [[0x00, 0x00, 0x00, 0x00], + $Rcon = [ + [0x00, 0x00, 0x00, 0x00], [0x01, 0x00, 0x00, 0x00], [0x02, 0x00, 0x00, 0x00], [0x04, 0x00, 0x00, 0x00], @@ -277,7 +280,8 @@ function plugin_accounts_KeyExpansion($key) [0x40, 0x00, 0x00, 0x00], [0x80, 0x00, 0x00, 0x00], [0x1b, 0x00, 0x00, 0x00], - [0x36, 0x00, 0x00, 0x00]]; + [0x36, 0x00, 0x00, 0x00], + ]; $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) $Nk = count($key) / 4; // key length (in words): 4/6/8 for 128/192/256-bit keys $Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys @@ -316,7 +320,8 @@ function plugin_accounts_KeyExpansion($key) */ function plugin_accounts_SubWord($w) { - $Sbox = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + $Sbox = [ + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, @@ -331,7 +336,8 @@ function plugin_accounts_SubWord($w) 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16, + ]; for ($i = 0; $i < 4; $i++) { $w[$i] = $Sbox[$w[$i]]; }