Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@ public function updateGroupOrder(mixed $groups=null): JSONResponse

try {
$this->settingsService->setGroupOrder(groupIds: $groups);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException) {
// ADR-005: do not leak raw exception messages.
return new JSONResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Invalid groups payload'],
statusCode: Http::STATUS_BAD_REQUEST
);
}
Expand Down
20 changes: 12 additions & 8 deletions lib/Controller/DashboardApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,10 @@ public function getGroup(
groupId: $groupId,
uuid: $uuid
);
} catch (DoesNotExistException $e) {
} catch (DoesNotExistException) {
// ADR-005: do not leak raw exception messages to clients.
return new JSONResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Dashboard not found'],
statusCode: Http::STATUS_NOT_FOUND
);
}
Expand Down Expand Up @@ -496,9 +497,10 @@ public function updateGroup(
return ResponseHelper::success(
data: ['dashboard' => $dashboard->jsonSerialize()]
);
} catch (DoesNotExistException $e) {
} catch (DoesNotExistException) {
// ADR-005: do not leak raw exception messages to clients.
return new JSONResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Dashboard not found'],
statusCode: Http::STATUS_NOT_FOUND
);
} catch (\Exception $e) {
Expand Down Expand Up @@ -543,9 +545,10 @@ public function deleteGroup(
);

return ResponseHelper::success(data: ['status' => 'ok']);
} catch (DoesNotExistException $e) {
} catch (DoesNotExistException) {
// ADR-005: do not leak raw exception messages to clients.
return new JSONResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Dashboard not found'],
statusCode: Http::STATUS_NOT_FOUND
);
} catch (\Exception $e) {
Expand Down Expand Up @@ -608,9 +611,10 @@ public function setGroupDefault(
'uuid' => $uuid,
]
);
} catch (DoesNotExistException $e) {
} catch (DoesNotExistException) {
// ADR-005: do not leak raw exception messages to clients.
return new JSONResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Dashboard not found'],
statusCode: Http::STATUS_NOT_FOUND
);
} catch (\Exception $e) {
Expand Down
35 changes: 21 additions & 14 deletions lib/Controller/DashboardShareApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
{
if ($this->userId === null) {
return new DataResponse(
data: ['error' => 'Not logged in'],

Check failure on line 75 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<string, string> given.
statusCode: Http::STATUS_UNAUTHORIZED
);
}
Expand All @@ -86,15 +86,16 @@
callback: static fn($s) => $s->jsonSerialize(),
array: $shares
);
return new DataResponse(data: $serialized);

Check failure on line 89 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<array> given.
} catch (DoesNotExistException) {
return new DataResponse(
data: ['error' => 'Dashboard not found'],

Check failure on line 92 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<string, string> given.
statusCode: Http::STATUS_NOT_FOUND
);
} catch (Exception $e) {
} catch (Exception) {
// ADR-005: do not leak raw exception messages to clients.
return new DataResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Forbidden'],

Check failure on line 98 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<string, string> given.
statusCode: Http::STATUS_FORBIDDEN
);
}//end try
Expand All @@ -119,7 +120,7 @@
): DataResponse {
if ($this->userId === null) {
return new DataResponse(
data: ['error' => 'Not logged in'],

Check failure on line 123 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<string, string> given.
statusCode: Http::STATUS_UNAUTHORIZED
);
}
Expand All @@ -133,22 +134,24 @@
callerId: $this->userId
);
return new DataResponse(
data: $share->jsonSerialize(),

Check failure on line 137 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array given.
statusCode: Http::STATUS_CREATED
);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException) {
// ADR-005: do not leak raw exception messages to clients.
return new DataResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Invalid request'],

Check failure on line 143 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<string, string> given.
statusCode: Http::STATUS_BAD_REQUEST
);
} catch (DoesNotExistException) {
return new DataResponse(
data: ['error' => 'Dashboard not found'],

Check failure on line 148 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<string, string> given.
statusCode: Http::STATUS_NOT_FOUND
);
} catch (Exception $e) {
} catch (Exception) {
// ADR-005: do not leak raw exception messages to clients.
return new DataResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Forbidden'],

Check failure on line 154 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<string, string> given.
statusCode: Http::STATUS_FORBIDDEN
);
}//end try
Expand All @@ -166,7 +169,7 @@
{
if ($this->userId === null) {
return new DataResponse(
data: ['error' => 'Not logged in'],

Check failure on line 172 in lib/Controller/DashboardShareApiController.php

View workflow job for this annotation

GitHub Actions / quality / PHP Quality (phpstan)

Parameter $data of class OCP\AppFramework\Http\DataResponse constructor expects T of OCP\AppFramework\Http\DataResponseType, array<string, string> given.
statusCode: Http::STATUS_UNAUTHORIZED
);
}
Expand All @@ -182,9 +185,10 @@
data: ['error' => 'Share not found'],
statusCode: Http::STATUS_NOT_FOUND
);
} catch (Exception $e) {
} catch (Exception) {
// ADR-005: do not leak raw exception messages to clients.
return new DataResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Forbidden'],
statusCode: Http::STATUS_FORBIDDEN
);
}//end try
Expand Down Expand Up @@ -223,19 +227,21 @@
array: $newShares
);
return new DataResponse(data: $serialized);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException) {
// ADR-005: do not leak raw exception messages to clients.
return new DataResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Invalid request'],
statusCode: Http::STATUS_BAD_REQUEST
);
} catch (DoesNotExistException) {
return new DataResponse(
data: ['error' => 'Dashboard not found'],
statusCode: Http::STATUS_NOT_FOUND
);
} catch (Exception $e) {
} catch (Exception) {
// ADR-005: do not leak raw exception messages to clients.
return new DataResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Forbidden'],
statusCode: Http::STATUS_FORBIDDEN
);
}//end try
Expand Down Expand Up @@ -269,9 +275,10 @@
callerId: $this->userId
);
return new DataResponse(data: ['deleted' => $count]);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException) {
// ADR-005: do not leak raw exception messages to clients.
return new DataResponse(
data: ['error' => $e->getMessage()],
data: ['error' => 'Invalid request'],
statusCode: Http::STATUS_BAD_REQUEST
);
}
Expand Down
Loading