From dab1057395c8eb9c5dce5480a738de1467e83ba5 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 26 Mar 2018 19:45:10 +0000 Subject: [PATCH] Improved input checking for role editor. --- WEB-INF/templates/footer.tpl | 2 +- role_add.php | 3 ++- role_delete.php | 7 ++++++- role_edit.php | 4 ++-- roles.php | 3 ++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 6646f126..7c8bd634 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.74.4181 | Copyright © Anuko | +  Anuko Time Tracker 1.17.74.4182 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/role_add.php b/role_add.php index e4cbb964..d26cb6ad 100644 --- a/role_add.php +++ b/role_add.php @@ -40,7 +40,7 @@ if (!ttAccessAllowed('manage_roles')) { if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); $cl_description = trim($request->getParameter('description')); - $cl_rank = (int) $request->getParameter('rank'); + $cl_rank = (int)$request->getParameter('rank'); } $form = new Form('roleForm'); @@ -56,6 +56,7 @@ if ($request->isPost()) { // Validate user input. if (!ttValidString($cl_name)) $err->add($i18n->get('error.field'), $i18n->get('label.thing_name')); if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description')); + if ($cl_rank >= $user->rank || $cl_rank < 0) $err->add($i18n->get('error.field'), $i18n->get('form.roles.rank')); if ($err->no()) { $existing_role = ttRoleHelper::getRoleByRank($cl_rank, $user->team_id); diff --git a/role_delete.php b/role_delete.php index 086e7aff..a3ce2985 100644 --- a/role_delete.php +++ b/role_delete.php @@ -35,9 +35,14 @@ if (!ttAccessAllowed('manage_roles')) { header('Location: access_denied.php'); exit(); } - $cl_role_id = (int)$request->getParameter('id'); $role = ttRoleHelper::get($cl_role_id); +if (!$role) { + header('Location: access_denied.php'); + exit(); +} +// End of access checks. + $role_to_delete = $role['name']; $form = new Form('roleDeleteForm'); diff --git a/role_edit.php b/role_edit.php index f5f3762b..972d4540 100644 --- a/role_edit.php +++ b/role_edit.php @@ -28,8 +28,6 @@ require_once('initialize.php'); import('form.Form'); -import('ttTeamHelper'); // TODO: remove this? -import('ttTaskHelper'); // TODO: remove this? import('ttRoleHelper'); // Access checks. @@ -43,6 +41,7 @@ if (!$role) { header('Location: access_denied.php'); exit(); } +// End of access checks. $assigned_rights = explode(',', $role['rights']); $available_rights = array_diff($user->rights, $assigned_rights); @@ -82,6 +81,7 @@ if ($request->isPost()) { // Validate user input. if (!ttValidString($cl_name)) $err->add($i18n->get('error.field'), $i18n->get('label.thing_name')); if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description')); + if ($cl_rank >= $user->rank || $cl_rank < 0) $err->add($i18n->get('error.field'), $i18n->get('form.roles.rank')); if ($err->no()) { $existing_role = ttRoleHelper::getRoleByName($cl_name); diff --git a/roles.php b/roles.php index ec79020e..cd17da3c 100644 --- a/roles.php +++ b/roles.php @@ -31,11 +31,12 @@ import('form.Form'); import('ttTeamHelper'); import('ttRoleHelper'); -// Access check. +// Access checks. if (!ttAccessAllowed('manage_roles')) { header('Location: access_denied.php'); exit(); } +// End of access checks. $smarty->assign('active_roles', ttTeamHelper::getActiveRolesForUser()); $smarty->assign('inactive_roles', ttTeamHelper::getInactiveRolesForUser()); -- 2.20.1