diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php index 539c667b8973c..0d83c29b7b4d2 100644 --- a/apps/user_ldap/lib/User/Manager.php +++ b/apps/user_ldap/lib/User/Manager.php @@ -166,8 +166,13 @@ function ($list, $attribute) { * @param string $id the Nextcloud username */ public function isDeletedUser(string $id): bool { - return $this->userConfig->getValueBool( - $id, 'user_ldap', 'isDeleted'); + try { + return $this->userConfig->getValueBool($id, 'user_ldap', 'isDeleted'); + } catch (\InvalidArgumentException $e) { + // Most likely the string is too long to be a valid user id + $this->logger->debug('Invalid id given to isDeletedUser', ['exception' => $e]); + return false; + } } /** diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index f7d135c134d7b..5a5488e34187e 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -1715,6 +1715,7 @@ private function isFlagged(int $needle, int $flags): bool { * @param bool $allowEmptyUser * @param bool $allowEmptyApp $app can be empty string * @param ValueType|null $valueType assert value type is only one type + * @throws InvalidArgumentException if userId, app, or prefKey is invalid (too long, or empty string) */ private function assertParams( string $userId = '', diff --git a/lib/public/Config/IUserConfig.php b/lib/public/Config/IUserConfig.php index ac9e67d569585..0c50c349d5a48 100644 --- a/lib/public/Config/IUserConfig.php +++ b/lib/public/Config/IUserConfig.php @@ -52,6 +52,7 @@ interface IUserConfig { * @param string $appId optional id of app * * @return list list of userIds + * @throws \InvalidArgumentException if $appId is invalid (too long) * * @since 32.0.0 */ @@ -66,6 +67,7 @@ public function getUserIds(string $appId = ''): array; * @param string $userId id of the user * * @return list list of app ids + * @throws \InvalidArgumentException if $userId is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -81,6 +83,7 @@ public function getApps(string $userId): array; * @param string $app id of the app * * @return list list of stored config keys + * @throws \InvalidArgumentException if $userId or $app is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -95,6 +98,7 @@ public function getKeys(string $userId, string $app): array; * @param bool $lazy search within lazy loaded config * * @return bool TRUE if key exists + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -110,6 +114,7 @@ public function hasKey(string $userId, string $app, string $key, ?bool $lazy = f * * @return bool TRUE if value is sensitive * @throws UnknownKeyException if config key is not known + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -130,6 +135,7 @@ public function isSensitive(string $userId, string $app, string $key, ?bool $laz * * @return bool TRUE if value is sensitive * @throws UnknownKeyException if config key is not known + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -146,6 +152,7 @@ public function isIndexed(string $userId, string $app, string $key, ?bool $lazy * * @return bool TRUE if config is lazy loaded * @throws UnknownKeyException if config key is not known + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * @see IUserConfig for details about lazy loading * * @since 32.0.0 @@ -164,6 +171,7 @@ public function isLazy(string $userId, string $app, string $key): bool; * @param bool $filtered filter sensitive config values * * @return array [key => value] + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -179,6 +187,7 @@ public function getValues(string $userId, string $app, string $prefix = '', bool * @param bool $filtered filter sensitive config values * * @return array [key => value] + * @throws \InvalidArgumentException if $userId is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -194,6 +203,7 @@ public function getAllValues(string $userId, bool $filtered = false): array; * @param ValueType|null $typedAs enforce type for the returned values * * @return array [appId => value] + * @throws \InvalidArgumentException if $userId or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -211,6 +221,7 @@ public function getValuesByApps(string $userId, string $key, bool $lazy = false, * @param array|null $userIds limit the search to a list of user ids * * @return array [userId => value] + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -228,6 +239,7 @@ public function getValuesByUsers(string $app, string $key, ?ValueType $typedAs = * @param bool $caseInsensitive non-case-sensitive search, only works if $value is a string * * @return Generator + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -244,6 +256,7 @@ public function searchUsersByValueString(string $app, string $key, string $value * @param int $value config value * * @return Generator + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -260,6 +273,7 @@ public function searchUsersByValueInt(string $app, string $key, int $value): Gen * @param array $values list of possible config values * * @return Generator + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -276,6 +290,7 @@ public function searchUsersByValues(string $app, string $key, array $values): Ge * @param bool $value config value * * @return Generator + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -293,6 +308,7 @@ public function searchUsersByValueBool(string $app, string $key, bool $value): G * @param bool $lazy search within lazy loaded config * * @return string stored config value or $default if not set in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -316,6 +332,7 @@ public function getValueString(string $userId, string $app, string $key, string * @param bool $lazy search within lazy loaded config * * @return int stored config value or $default if not set in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -339,6 +356,7 @@ public function getValueInt(string $userId, string $app, string $key, int $defau * @param bool $lazy search within lazy loaded config * * @return float stored config value or $default if not set in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -362,6 +380,7 @@ public function getValueFloat(string $userId, string $app, string $key, float $d * @param bool $lazy search within lazy loaded config * * @return bool stored config value or $default if not set in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -385,6 +404,7 @@ public function getValueBool(string $userId, string $app, string $key, bool $def * @param bool $lazy search within lazy loaded config * * @return array stored config value or $default if not set in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -410,6 +430,7 @@ public function getValueArray(string $userId, string $app, string $key, array $d * @return ValueType type of the value * @throws UnknownKeyException if config key is not known * @throws IncorrectTypeException if config value type is not known + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -429,6 +450,7 @@ public function getValueType(string $userId, string $app, string $key, ?bool $la * @return int a bitflag in relation to the config value * @throws UnknownKeyException if config key is not known * @throws IncorrectTypeException if config value type is not known + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -450,6 +472,7 @@ public function getValueFlags(string $userId, string $app, string $key, bool $la * @param bool $lazy set config as lazy loaded * * @return bool TRUE if value was different, therefor updated in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -482,6 +505,7 @@ public function setValueString(string $userId, string $app, string $key, string * @param bool $lazy set config as lazy loaded * * @return bool TRUE if value was different, therefor updated in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -509,6 +533,7 @@ public function setValueInt(string $userId, string $app, string $key, int $value * @param bool $lazy set config as lazy loaded * * @return bool TRUE if value was different, therefor updated in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -535,6 +560,7 @@ public function setValueFloat(string $userId, string $app, string $key, float $v * @param bool $lazy set config as lazy loaded * * @return bool TRUE if value was different, therefor updated in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -562,6 +588,7 @@ public function setValueBool(string $userId, string $app, string $key, bool $val * @param bool $lazy set config as lazy loaded * * @return bool TRUE if value was different, therefor updated in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 * @@ -584,6 +611,7 @@ public function setValueArray(string $userId, string $app, string $key, array $v * @param bool $sensitive TRUE to set as sensitive, FALSE to unset * * @return bool TRUE if database update were necessary + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -597,6 +625,7 @@ public function updateSensitive(string $userId, string $app, string $key, bool $ * @param string $app id of the app * @param string $key config key * @param bool $sensitive TRUE to set as sensitive, FALSE to unset + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -614,6 +643,7 @@ public function updateGlobalSensitive(string $app, string $key, bool $sensitive) * @param bool $indexed TRUE to set as indexed, FALSE to unset * * @return bool TRUE if database update were necessary + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -627,6 +657,7 @@ public function updateIndexed(string $userId, string $app, string $key, bool $in * @param string $app id of the app * @param string $key config key * @param bool $indexed TRUE to set as indexed, FALSE to unset + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -641,6 +672,7 @@ public function updateGlobalIndexed(string $app, string $key, bool $indexed): vo * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset * * @return bool TRUE if database update was necessary + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -654,6 +686,7 @@ public function updateLazy(string $userId, string $app, string $key, bool $lazy) * @param string $app id of the app * @param string $key config key * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -680,6 +713,7 @@ public function updateGlobalLazy(string $app, string $key, bool $lazy): void; * * @return array * @throws UnknownKeyException if config key is not known in database + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -691,6 +725,7 @@ public function getDetails(string $userId, string $app, string $key): array; * @param string $userId id of the user * @param string $app id of the app * @param string $key config key + * @throws \InvalidArgumentException if $userId, $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -701,6 +736,7 @@ public function deleteUserConfig(string $userId, string $app, string $key): void * * @param string $app id of the app * @param string $key config key + * @throws \InvalidArgumentException if $app or $key is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -710,6 +746,7 @@ public function deleteKey(string $app, string $key): void; * delete all config keys linked to an app * * @param string $app id of the app + * @throws \InvalidArgumentException if $app is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -719,6 +756,7 @@ public function deleteApp(string $app): void; * delete all config keys linked to a user * * @param string $userId id of the user + * @throws \InvalidArgumentException if $userId is invalid (too long, or empty string) * * @since 32.0.0 */ @@ -731,6 +769,7 @@ public function deleteAllUserConfig(string $userId): void; * * @param string $userId id of the user * @param bool $reload set to TRUE to refill cache instantly after clearing it + * @throws \InvalidArgumentException if $userId is invalid (too long, or empty string) * * @since 32.0.0 */