chore: add stricter checks according to review

This commit is contained in:
Chirag Aggarwal
2025-04-18 15:32:25 +00:00
parent ba22e5f457
commit d130e7d3bd
7 changed files with 13 additions and 12 deletions
@@ -82,12 +82,13 @@ class Create extends Action
$fileSecurity = $bucket->getAttribute('fileSecurity', false);
$validator = new Authorization(Database::PERMISSION_UPDATE);
$bucketPermission = $validator->isValid($bucket->getUpdate());
if (!$fileSecurity && !$bucketPermission) {
throw new Exception(Exception::USER_UNAUTHORIZED);
}
$filePermission = $validator->isValid($file->getUpdate());
if ($fileSecurity && !$bucketPermission && !$filePermission) {
if ($fileSecurity) {
$filePermission = $validator->isValid($file->getUpdate());
if (!$bucketPermission && !$filePermission) {
throw new Exception(Exception::USER_UNAUTHORIZED);
}
} elseif (!$bucketPermission) {
throw new Exception(Exception::USER_UNAUTHORIZED);
}
@@ -66,7 +66,7 @@ class Get extends Action
// calculate maxAge based on expiry date
$maxAge = PHP_INT_MAX;
$expire = $token->getAttribute('expire');
if ($expire != null) {
if ($expire !== null) {
$now = new \DateTime();
$expiryDate = new \DateTime($expire);
if ($expiryDate < $now) {
@@ -177,7 +177,7 @@ class OpenAPI3 extends Format
$namespace = $sdk->getNamespace() ?? 'default';
$desc = $desc ?? '';
$desc ??= '';
$descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc;
$temp = [
@@ -173,7 +173,7 @@ class Swagger2 extends Format
$namespace = $sdk->getNamespace() ?? 'default';
$desc = $desc ?? '';
$desc ??= '';
$descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc;
$temp = [