-
-
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
LDAP variables can be integers #35701
Changes from 1 commit
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 |
---|---|---|
|
@@ -703,7 +703,8 @@ public function getUserGroups($uid) { | |
if ($userMatch !== false) { | ||
// match found so this user is in this group | ||
$groupName = $this->access->dn2groupname($dynamicGroup['dn'][0]); | ||
if (is_string($groupName)) { | ||
// in case it is just an integer (is_string(int) returns false | ||
if (is_string($groupName) || is_numeric($groupName)) { | ||
Check notice Code scanning / Psalm DocblockTypeContradiction
Docblock-defined type false for $groupName is never numeric
|
||
// be sure to never return false if the dn could not be | ||
// resolved to a name, for whatever reason. | ||
$groups[] = $groupName; | ||
|
@@ -730,7 +731,8 @@ public function getUserGroups($uid) { | |
$groupDNs = $this->_getGroupDNsFromMemberOf($userDN); | ||
foreach ($groupDNs as $dn) { | ||
$groupName = $this->access->dn2groupname($dn); | ||
if (is_string($groupName)) { | ||
// in case it is just an integer (is_string(int) returns false | ||
if (is_string($groupName) || is_numeric($groupName)) { | ||
Check notice Code scanning / Psalm DocblockTypeContradiction
Docblock-defined type false for $groupName is never numeric
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. why can't the name of a group be just numbers? |
||
// be sure to never return false if the dn could not be | ||
// resolved to a name, for whatever reason. | ||
$groups[] = $groupName; | ||
|
@@ -1138,7 +1140,8 @@ public function groupExists($gid) { | |
protected function filterValidGroups(array $listOfGroups): array { | ||
$validGroupDNs = []; | ||
foreach ($listOfGroups as $key => $item) { | ||
$dn = is_string($item) ? $item : $item['dn'][0]; | ||
// in case it is just an integer (is_string(int) returns false | ||
$dn = !is_array($item) ? $item : $item['dn'][0]; | ||
if (is_array($item) && !isset($item[$this->access->connection->ldapGroupDisplayName][0])) { | ||
continue; | ||
} | ||
|
@@ -1191,7 +1194,8 @@ public function createGroup($gid) { | |
if ($dn = $this->groupPluginManager->createGroup($gid)) { | ||
//updates group mapping | ||
$uuid = $this->access->getUUID($dn, false); | ||
if (is_string($uuid)) { | ||
// in case it is just an integer, not sure if this UUID could ever be an int though | ||
if (is_string($uuid) || is_numeric($uuid)) { | ||
Check notice Code scanning / Psalm DocblockTypeContradiction
Docblock-defined type false for $uuid is never numeric
|
||
$this->access->mapAndAnnounceIfApplicable( | ||
$this->access->getGroupMapper(), | ||
$dn, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,7 +192,8 @@ public function setUUIDbyDN($uuid, $fdn): bool { | |
*/ | ||
protected function getDNHash(string $fdn): string { | ||
$hash = hash('sha256', $fdn, false); | ||
if (is_string($hash)) { | ||
// very rare but a hash could just be numbers? is_string(int) would return false | ||
if (is_string($hash) || is_numeric($hash)) { | ||
Check failure Code scanning / Psalm TypeDoesNotContainType
Type false for $hash is never numeric
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. in theory a sha256 can return just numbers. PHP will parse that as numeric and not a string AFAIK. |
||
return $hash; | ||
} else { | ||
throw new \RuntimeException('hash function did not return a string'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -304,7 +304,8 @@ public function getUsers($search = '', $limit = 10, $offset = 0) { | |
* @throws \OC\ServerNotAvailableException | ||
*/ | ||
public function userExistsOnLDAP($user, bool $ignoreCache = false): bool { | ||
if (is_string($user)) { | ||
// in case it is just an integer (is_string(int) returns false | ||
if (is_string($user) || is_numeric($user)) { | ||
Check notice Code scanning / Psalm DocblockTypeContradiction
Docblock-defined type OCA\User_LDAP\User\User for $user is never numeric
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. Why can't the username be just numbers? |
||
$user = $this->access->userManager->get($user); | ||
} | ||
if (is_null($user)) { | ||
|
@@ -645,7 +646,8 @@ public function createUser($username, $password) { | |
if (is_string($dn)) { | ||
// the NC user creation work flow requires a know user id up front | ||
$uuid = $this->access->getUUID($dn, true); | ||
if (is_string($uuid)) { | ||
// not sure if UUID could ever be just a number | ||
if (is_string($uuid) || is_numeric($uuid)) { | ||
Check notice Code scanning / Psalm DocblockTypeContradiction
Docblock-defined type false for $uuid is never numeric
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. IDK what UUID is but if it can ever be a string of integers, PHP parses that as an integer not a string (no typecasting) |
||
$this->access->mapAndAnnounceIfApplicable( | ||
$this->access->getUserMapper(), | ||
$dn, | ||
|
Check failure
Code scanning / Psalm
UndefinedVariable
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.
oops, that's my mistake!