Skip to content

Commit 7d9f105

Browse files
committed
Making sure the input properties are validated before ACL check method is invoked (so ACLs are checked on validated inputs).
1 parent 4efca5f commit 7d9f105

3 files changed

Lines changed: 27 additions & 25 deletions

File tree

app/V1Module/presenters/base/BasePresenter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ public function startup()
127127
$this->verifyUserIpLock($user);
128128
}
129129

130-
// ACL-checking method
131-
$this->tryCall($this->formatPermissionCheckMethod($this->getAction()), $this->params);
132-
133130
Validators::init();
134131
$this->processParams($actionReflection);
132+
133+
// ACL-checking method
134+
$this->tryCall($this->formatPermissionCheckMethod($this->getAction()), $this->params);
135135
}
136136

137137
protected function isRequestJson(): bool

tests/Presenters/ExercisesPresenter.phpt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,15 +1106,32 @@ class TestExercisesPresenter extends Tester\TestCase
11061106
});
11071107
$exercise = current($exercises);
11081108

1109+
$postBody = [
1110+
'version' => 1,
1111+
'difficulty' => 'super hard',
1112+
'isPublic' => false,
1113+
'localizedTexts' => [
1114+
[
1115+
'locale' => 'cs',
1116+
'text' => 'new descr',
1117+
'name' => 'new name',
1118+
'description' => 'some neaty description'
1119+
]
1120+
],
1121+
'solutionFilesLimit' => 3,
1122+
'solutionSizeLimit' => 42,
1123+
'mergeJudgeLogs' => false,
1124+
];
1125+
11091126
// another supervisor cannot update this exercise
11101127
Assert::exception(
1111-
function () use ($exercise) {
1128+
function () use ($exercise, $postBody) {
11121129
PresenterTestHelper::performPresenterRequest(
11131130
$this->presenter,
11141131
'V1:Exercises',
11151132
'POST',
11161133
['action' => 'updateDetail', 'id' => $exercise->getId()],
1117-
[]
1134+
$postBody
11181135
);
11191136
},
11201137
ForbiddenRequestException::class
@@ -1130,22 +1147,7 @@ class TestExercisesPresenter extends Tester\TestCase
11301147
'V1:Exercises',
11311148
'POST',
11321149
['action' => 'updateDetail', 'id' => $exercise->getId()],
1133-
[
1134-
'version' => 1,
1135-
'difficulty' => 'super hard',
1136-
'isPublic' => false,
1137-
'localizedTexts' => [
1138-
[
1139-
'locale' => 'cs',
1140-
'text' => 'new descr',
1141-
'name' => 'new name',
1142-
'description' => 'some neaty description'
1143-
]
1144-
],
1145-
'solutionFilesLimit' => 3,
1146-
'solutionSizeLimit' => 42,
1147-
'mergeJudgeLogs' => false,
1148-
]
1150+
$postBody
11491151
);
11501152
$response = $this->presenter->run($request);
11511153
Assert::type(Nette\Application\Responses\JsonResponse::class, $response);

tests/Security/UserLocking.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ class UserLocking extends Tester\TestCase
572572
'V1:Comments',
573573
'POST',
574574
['action' => 'addComment', 'id' => $solution->getId()],
575-
['text' => 'some comment text', 'isPrivate' => 'false']
575+
['text' => 'some comment text', 'isPrivate' => false]
576576
);
577577
},
578578
App\Exceptions\ForbiddenRequestException::class
@@ -610,7 +610,7 @@ class UserLocking extends Tester\TestCase
610610
'V1:Comments',
611611
'POST',
612612
['action' => 'addComment', 'id' => $solution->getId()],
613-
['text' => 'some comment text', 'isPrivate' => 'false']
613+
['text' => 'some comment text', 'isPrivate' => false]
614614
);
615615
},
616616
App\Exceptions\ForbiddenRequestException::class
@@ -639,7 +639,7 @@ class UserLocking extends Tester\TestCase
639639
'V1:Comments',
640640
'POST',
641641
['action' => 'addComment', 'id' => $assignment->getId()],
642-
['text' => 'some comment text', 'isPrivate' => 'false']
642+
['text' => 'some comment text', 'isPrivate' => false]
643643
);
644644
},
645645
App\Exceptions\ForbiddenRequestException::class
@@ -671,7 +671,7 @@ class UserLocking extends Tester\TestCase
671671
'V1:Comments',
672672
'POST',
673673
['action' => 'addComment', 'id' => $assignment->getId()],
674-
['text' => 'some comment text', 'isPrivate' => 'false']
674+
['text' => 'some comment text', 'isPrivate' => false]
675675
);
676676
},
677677
App\Exceptions\ForbiddenRequestException::class

0 commit comments

Comments
 (0)