Merge pull request #750 from nextcloud/fix/update_restrictions

Harden update restrictions
This commit is contained in:
John Molakvoæ 2021-02-17 12:09:41 +01:00 коммит произвёл GitHub
Родитель 8a93ba56a7 a9b1d7e1ff
Коммит 2663092fa1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 40 добавлений и 2 удалений

Просмотреть файл

@ -252,7 +252,20 @@ class ApiController extends Controller {
throw new OCSForbiddenException();
}
// Make sure we only store id
// Don't allow empty array
if (sizeof($keyValuePairs) === 0) {
$this->logger->info('Empty keyValuePairs, will not update.');
throw new OCSForbiddenException();
}
// Don't allow to change params id, hash, ownerId, created
if (key_exists('id', $keyValuePairs) || key_exists('hash', $keyValuePairs) ||
key_exists('ownerId', $keyValuePairs) || key_exists('created', $keyValuePairs)) {
$this->logger->info('Not allowed to update id, hash, ownerId or created');
throw new OCSForbiddenException();
}
// Make sure we only store id of shares
try {
if (array_key_exists('access', $keyValuePairs)) {
$keyValuePairs['access']['users'] = array_map(function (array $user): string {
@ -496,7 +509,20 @@ class ApiController extends Controller {
throw new OCSForbiddenException();
}
if (array_key_exists('order', $keyValuePairs)) {
// Don't allow empty array
if (sizeof($keyValuePairs) === 0) {
$this->logger->info('Empty keyValuePairs, will not update.');
throw new OCSForbiddenException();
}
//Don't allow to change id or formId
if (key_exists('id', $keyValuePairs) || key_exists('formId', $keyValuePairs)) {
$this->logger->debug('Not allowed to update id or formId');
throw new OCSForbiddenException();
}
// Don't allow to reorder here
if (key_exists('order', $keyValuePairs)) {
$this->logger->debug('Key \'order\' is not allowed on updateQuestion. Please use reorderQuestions() to change order.');
throw new OCSForbiddenException('Please use reorderQuestions() to change order');
}
@ -632,6 +658,18 @@ class ApiController extends Controller {
throw new OCSForbiddenException();
}
// Don't allow empty array
if (sizeof($keyValuePairs) === 0) {
$this->logger->info('Empty keyValuePairs, will not update.');
throw new OCSForbiddenException();
}
//Don't allow to change id or questionId
if (key_exists('id', $keyValuePairs) || key_exists('questionId', $keyValuePairs)) {
$this->logger->debug('Not allowed to update id or questionId');
throw new OCSForbiddenException();
}
// Create OptionEntity with given Params & Id.
$option = Option::fromParams($keyValuePairs);
$option->setId($id);