-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Harden user_status API #49797
base: master
Are you sure you want to change the base?
Harden user_status API #49797
Changes from all commits
f1c6e96
ad729b1
a0f18aa
18b4a62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ class UserStatusController extends OCSController { | |
public function __construct( | ||
string $appName, | ||
IRequest $request, | ||
private string $userId, | ||
private ?string $userId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any chance to explain psalm and friends that such a property cannot be null when calling an authenticated method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that is possible and even then we'd still have a problem because the DI will fail when you don't send the authentication (regardless if the method needs it or not). |
||
private LoggerInterface $logger, | ||
private StatusService $service, | ||
private CalendarStatusService $calendarStatusService, | ||
|
@@ -123,6 +123,7 @@ public function setPredefinedMessage(string $messageId, | |
* @param int|null $clearAt When the message should be cleared | ||
* @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}> | ||
* @throws OCSBadRequestException The clearAt or icon is invalid or the message is too long | ||
* @throws OCSNotFoundException No status for the current user | ||
* | ||
* 200: The message was updated successfully | ||
*/ | ||
|
@@ -149,6 +150,8 @@ public function setCustomMessage(?string $statusIcon, | |
} catch (StatusMessageTooLongException $ex) { | ||
$this->logger->debug('New user-status for "' . $this->userId . '" was rejected due to a too long status message.'); | ||
throw new OCSBadRequestException($ex->getMessage(), $ex); | ||
} catch (DoesNotExistException $ex) { | ||
throw new OCSNotFoundException('No status for the current user'); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m curious, I guess a lot of places in the API expects a positive int and type it as int, why change this one in particular?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this one because the fuzzer used -1 which triggered an unexpected error.
I didn't search for these problems, but the underlying typing could be improved to find more of them.