From 3e0f14ae2b0b5a44bd038a472f17eac75f538524 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 23 Sep 2017 20:56:54 -0700 Subject: Do not expose IDs in forms --- app/Controller/BaseController.php | 62 ++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 8 deletions(-) (limited to 'app/Controller/BaseController.php') diff --git a/app/Controller/BaseController.php b/app/Controller/BaseController.php index 1ac7ed20..41fcef1c 100644 --- a/app/Controller/BaseController.php +++ b/app/Controller/BaseController.php @@ -138,14 +138,7 @@ abstract class BaseController extends Base return $user; } - /** - * Get the current subtask - * - * @access protected - * @return array - * @throws PageNotFoundException - */ - protected function getSubtask() + protected function getSubtask(array $task) { $subtask = $this->subtaskModel->getById($this->request->getIntegerParam('subtask_id')); @@ -153,9 +146,62 @@ abstract class BaseController extends Base throw new PageNotFoundException(); } + if ($subtask['task_id'] != $task['id']) { + throw new AccessForbiddenException(); + } + return $subtask; } + protected function getComment(array $task) + { + $comment = $this->commentModel->getById($this->request->getIntegerParam('comment_id')); + + if (empty($comment)) { + throw new PageNotFoundException(); + } + + if (! $this->userSession->isAdmin() && $comment['user_id'] != $this->userSession->getId()) { + throw new AccessForbiddenException(); + } + + if ($comment['task_id'] != $task['id']) { + throw new AccessForbiddenException(); + } + + return $comment; + } + + protected function getExternalTaskLink(array $task) + { + $link = $this->taskExternalLinkModel->getById($this->request->getIntegerParam('link_id')); + + if (empty($link)) { + throw new PageNotFoundException(); + } + + if ($link['task_id'] != $task['id']) { + throw new AccessForbiddenException(); + } + + return $link; + } + + protected function getInternalTaskLink(array $task) + { + $link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id')); + + if (empty($link)) { + throw new PageNotFoundException(); + } + + if ($link['task_id'] != $task['id']) { + throw new AccessForbiddenException(); + } + + return $link; + } + protected function getColumn(array $project) { $column = $this->columnModel->getById($this->request->getIntegerParam('column_id')); -- cgit v1.2.3