Skip to content
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

build(deps): bump vimeo/psalm from 5.9.0 to 5.23.1 in /vendor-bin/psalm #44533

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function __construct(View $view, FileInfo $info, ?IManager $shareManager
* different object on a subsequent GET you are strongly recommended to not
* return an ETag, and just return null.
*
* @param resource $data
* @param resource|string $data
*
* @throws Forbidden
* @throws UnsupportedMediaType
Expand Down
2 changes: 1 addition & 1 deletion apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ protected function analyse(string $sourceUid,

$encryptedFiles = [];
$this->walkFiles($view, $sourcePath,
function (FileInfo $fileInfo) use ($progress) {
function (FileInfo $fileInfo) use ($progress, &$encryptedFiles) {
if ($fileInfo->getType() === FileInfo::TYPE_FOLDER) {
// only analyze into folders from main storage,
if (!$fileInfo->getStorage()->instanceOfStorage(IHomeStorage::class)) {
Expand Down
3 changes: 3 additions & 0 deletions apps/files_external/lib/Lib/Storage/SFTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
try {
$keyPath = $this->hostKeysPath();
if ($keyPath && file_exists($keyPath)) {
$fp = fopen($keyPath, 'w');

Check failure on line 246 in apps/files_external/lib/Lib/Storage/SFTP.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedFile

apps/files_external/lib/Lib/Storage/SFTP.php:246:17: TaintedFile: Detected tainted file handling (see https://psalm.dev/255)
foreach ($keys as $host => $key) {
fwrite($fp, $host . '::' . $key . "\n");
}
Expand All @@ -264,7 +264,7 @@
if (file_exists($keyPath)) {
$hosts = [];
$keys = [];
$lines = file($keyPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

Check failure on line 267 in apps/files_external/lib/Lib/Storage/SFTP.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedFile

apps/files_external/lib/Lib/Storage/SFTP.php:267:19: TaintedFile: Detected tainted file handling (see https://psalm.dev/255)
if ($lines) {
foreach ($lines as $line) {
$hostKeyArray = explode("::", $line, 2);
Expand Down Expand Up @@ -409,7 +409,7 @@
case 'c':
case 'c+':
$context = stream_context_create(['sftp' => ['session' => $connection]]);
$handle = fopen($this->constructUrl($path), $mode, false, $context);

Check failure on line 412 in apps/files_external/lib/Lib/Storage/SFTP.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedFile

apps/files_external/lib/Lib/Storage/SFTP.php:412:22: TaintedFile: Detected tainted file handling (see https://psalm.dev/255)
return RetryWrapper::wrap($handle);
}
} catch (\Exception $e) {
Expand Down Expand Up @@ -513,6 +513,9 @@
$result = $this->getConnection()->put($this->absPath($path), $stream);
fclose($stream);
if ($result) {
if ($size === null) {
throw new \Exception("Failed to get written size from sftp storage wrapper");
}
return $size;
} else {
throw new \Exception("Failed to write steam to sftp storage");
Expand Down
4 changes: 3 additions & 1 deletion apps/settings/lib/SetupChecks/PhpOpcacheSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ protected function getOpcacheSetupRecommendations(): array {
$recommendations[] = $this->l10n->t('The OPcache buffer is nearly full. To assure that all scripts can be hold in cache, it is recommended to apply "opcache.memory_consumption" to your PHP configuration with a value higher than "%s".', [($this->iniGetWrapper->getNumeric('opcache.memory_consumption') ?: 'currently')]);
}

$interned_strings_buffer = $this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') ?? 0;
come-nc marked this conversation as resolved.
Show resolved Hide resolved
$memory_consumption = $this->iniGetWrapper->getNumeric('opcache.memory_consumption') ?? 0;
if (
// Do not recommend to raise the interned strings buffer size above a quarter of the total OPcache size
($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') ?? $this->iniGetWrapper->getNumeric('opcache.memory_consumption') > 0 ?? 0 / 4) &&
($interned_strings_buffer < ($memory_consumption / 4)) &&
(
empty($status['interned_strings_usage']['free_memory']) ||
($status['interned_strings_usage']['used_memory'] / $status['interned_strings_usage']['free_memory'] > 9)
Expand Down
10 changes: 5 additions & 5 deletions apps/theming/lib/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function generateRadioButton($color) {


/**
* @param $app string app name
* @param string $app app name
* @return string|ISimpleFile path to app icon / file of logo
*/
public function getAppIcon($app) {
Expand Down Expand Up @@ -248,8 +248,8 @@ public function getAppIcon($app) {
}

/**
* @param $app string app name
* @param $image string relative path to image in app folder
* @param string $app app name
* @param string $image relative path to image in app folder
* @return string|false absolute path to image
*/
public function getAppImage($app, $image) {
Expand Down Expand Up @@ -295,8 +295,8 @@ public function getAppImage($app, $image) {
/**
* replace default color with a custom one
*
* @param $svg string content of a svg file
* @param $color string color to match
* @param string $svg content of a svg file
* @param string $color color to match
* @return string
*/
public function colorizeSvg($svg, $color) {
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/ajax/wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

$con = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix, null);
$con->setConfiguration($configuration->getConfiguration());
$con->ldapConfigurationActive = true;
$con->ldapConfigurationActive = (string)true;
$con->setIgnoreValidation(true);

$factory = \OC::$server->get(\OCA\User_LDAP\AccessFactory::class);
Expand Down
72 changes: 70 additions & 2 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,76 @@
use Psr\Log\LoggerInterface;

/**
* @property int ldapPagingSize holds an integer
* @property string ldapUserAvatarRule
* @property string $ldapHost
* @property string $ldapPort
* @property string $ldapBackupHost
* @property string $ldapBackupPort
* @property string $ldapBackgroundHost
* @property string $ldapBackgroundPort
* @property array|'' $ldapBase
* @property array|'' $ldapBaseUsers
* @property array|'' $ldapBaseGroups
* @property string $ldapAgentName
* @property string $ldapAgentPassword
* @property string $ldapTLS
* @property string $turnOffCertCheck
* @property string $ldapIgnoreNamingRules
* @property string $ldapUserDisplayName
* @property string $ldapUserDisplayName2
* @property string $ldapUserAvatarRule
* @property string $ldapGidNumber
* @property array|'' $ldapUserFilterObjectclass
* @property array|'' $ldapUserFilterGroups
* @property string $ldapUserFilter
* @property string $ldapUserFilterMode
* @property string $ldapGroupFilter
* @property string $ldapGroupFilterMode
* @property array|'' $ldapGroupFilterObjectclass
* @property array|'' $ldapGroupFilterGroups
* @property string $ldapGroupDisplayName
* @property string $ldapGroupMemberAssocAttr
* @property string $ldapLoginFilter
* @property string $ldapLoginFilterMode
* @property string $ldapLoginFilterEmail
* @property string $ldapLoginFilterUsername
* @property array|'' $ldapLoginFilterAttributes
* @property string $ldapQuotaAttribute
* @property string $ldapQuotaDefault
* @property string $ldapEmailAttribute
* @property string $ldapCacheTTL
* @property string $ldapUuidUserAttribute
* @property string $ldapUuidGroupAttribute
* @property string $ldapOverrideMainServer
* @property string $ldapConfigurationActive
* @property array|'' $ldapAttributesForUserSearch
* @property array|'' $ldapAttributesForGroupSearch
* @property string $ldapExperiencedAdmin
* @property string $homeFolderNamingRule
* @property string $hasMemberOfFilterSupport
* @property string $useMemberOfToDetectMembership
* @property string $ldapExpertUsernameAttr
* @property string $ldapExpertUUIDUserAttr
* @property string $ldapExpertUUIDGroupAttr
* @property string $markRemnantsAsDisabled
* @property string $lastJpegPhotoLookup
* @property string $ldapNestedGroups
* @property string $ldapPagingSize
* @property string $turnOnPasswordChange
* @property string $ldapDynamicGroupMemberURL
* @property string $ldapDefaultPPolicyDN
* @property string $ldapExtStorageHomeAttribute
* @property string $ldapMatchingRuleInChainState
* @property string $ldapConnectionTimeout
* @property string $ldapAttributePhone
* @property string $ldapAttributeWebsite
* @property string $ldapAttributeAddress
* @property string $ldapAttributeTwitter
* @property string $ldapAttributeFediverse
* @property string $ldapAttributeOrganisation
* @property string $ldapAttributeRole
* @property string $ldapAttributeHeadline
* @property string $ldapAttributeBiography
* @property string $ldapAdminGroup
*/
class Configuration {
public const AVATAR_PREFIX_DEFAULT = 'default';
Expand Down
116 changes: 73 additions & 43 deletions apps/user_ldap/lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,49 +41,79 @@
use Psr\Log\LoggerInterface;

/**
* magic properties (incomplete)
* magic properties
* responsible for LDAP connections in context with the provided configuration
*
* @property string ldapHost
* @property string ldapPort holds the port number
* @property string ldapUserFilter
* @property string ldapUserDisplayName
* @property string ldapUserDisplayName2
* @property string ldapUserAvatarRule
* @property boolean turnOnPasswordChange
* @property string[] ldapBaseUsers
* @property int|null ldapPagingSize holds an integer
* @property bool|mixed|void ldapGroupMemberAssocAttr
* @property string ldapUuidUserAttribute
* @property string ldapUuidGroupAttribute
* @property string ldapExpertUUIDUserAttr
* @property string ldapExpertUUIDGroupAttr
* @property string ldapQuotaAttribute
* @property string ldapQuotaDefault
* @property string ldapEmailAttribute
* @property string ldapExtStorageHomeAttribute
* @property string homeFolderNamingRule
* @property bool|string markRemnantsAsDisabled
* @property bool|string ldapNestedGroups
* @property string[] ldapBaseGroups
* @property string ldapGroupFilter
* @property string ldapGroupDisplayName
* @property string ldapLoginFilter
* @property string ldapDynamicGroupMemberURL
* @property string ldapGidNumber
* @property int hasMemberOfFilterSupport
* @property int useMemberOfToDetectMembership
* @property string ldapMatchingRuleInChainState
* @property string ldapAttributePhone
* @property string ldapAttributeWebsite
* @property string ldapAttributeAddress
* @property string ldapAttributeTwitter
* @property string ldapAttributeFediverse
* @property string ldapAttributeOrganisation
* @property string ldapAttributeRole
* @property string ldapAttributeHeadline
* @property string ldapAttributeBiography
* @property string ldapAdminGroup
* @property string $ldapHost
* @property string $ldapPort
* @property string $ldapBackupHost
* @property string $ldapBackupPort
* @property string $ldapBackgroundHost
* @property string $ldapBackgroundPort
* @property array|'' $ldapBase
* @property array|'' $ldapBaseUsers
* @property array|'' $ldapBaseGroups
* @property string $ldapAgentName
* @property string $ldapAgentPassword
* @property string $ldapTLS
* @property string $turnOffCertCheck
* @property string $ldapIgnoreNamingRules
* @property string $ldapUserDisplayName
* @property string $ldapUserDisplayName2
* @property string $ldapUserAvatarRule
* @property string $ldapGidNumber
* @property array|'' $ldapUserFilterObjectclass
* @property array|'' $ldapUserFilterGroups
* @property string $ldapUserFilter
* @property string $ldapUserFilterMode
* @property string $ldapGroupFilter
* @property string $ldapGroupFilterMode
* @property array|'' $ldapGroupFilterObjectclass
* @property array|'' $ldapGroupFilterGroups
* @property string $ldapGroupDisplayName
* @property string $ldapGroupMemberAssocAttr
* @property string $ldapLoginFilter
* @property string $ldapLoginFilterMode
* @property string $ldapLoginFilterEmail
* @property string $ldapLoginFilterUsername
* @property array|'' $ldapLoginFilterAttributes
* @property string $ldapQuotaAttribute
* @property string $ldapQuotaDefault
* @property string $ldapEmailAttribute
* @property string $ldapCacheTTL
* @property string $ldapUuidUserAttribute
* @property string $ldapUuidGroupAttribute
* @property string $ldapOverrideMainServer
* @property string $ldapConfigurationActive
* @property array|'' $ldapAttributesForUserSearch
* @property array|'' $ldapAttributesForGroupSearch
* @property string $ldapExperiencedAdmin
* @property string $homeFolderNamingRule
* @property string $hasMemberOfFilterSupport
* @property string $useMemberOfToDetectMembership
* @property string $ldapExpertUsernameAttr
* @property string $ldapExpertUUIDUserAttr
* @property string $ldapExpertUUIDGroupAttr
* @property string $markRemnantsAsDisabled
* @property string $lastJpegPhotoLookup
* @property string $ldapNestedGroups
* @property string $ldapPagingSize
* @property string $turnOnPasswordChange
* @property string $ldapDynamicGroupMemberURL
* @property string $ldapDefaultPPolicyDN
* @property string $ldapExtStorageHomeAttribute
* @property string $ldapMatchingRuleInChainState
* @property string $ldapConnectionTimeout
* @property string $ldapAttributePhone
* @property string $ldapAttributeWebsite
* @property string $ldapAttributeAddress
* @property string $ldapAttributeTwitter
* @property string $ldapAttributeFediverse
* @property string $ldapAttributeOrganisation
* @property string $ldapAttributeRole
* @property string $ldapAttributeHeadline
* @property string $ldapAttributeBiography
* @property string $ldapAdminGroup
*/
class Connection extends LDAPUtility {
private ?\LDAP\Connection $ldapConnectionRes = null;
Expand Down Expand Up @@ -418,7 +448,7 @@ private function doSoftValidation(): void {

$backupPort = (int)$this->configuration->ldapBackupPort;
if ($backupPort <= 0) {
$this->configuration->backupPort = $this->configuration->ldapPort;
$this->configuration->ldapBackupPort = $this->configuration->ldapPort;
}

//make sure empty search attributes are saved as simple, empty array
Expand All @@ -433,7 +463,7 @@ private function doSoftValidation(): void {

if ((stripos((string)$this->configuration->ldapHost, 'ldaps://') === 0)
&& $this->configuration->ldapTLS) {
$this->configuration->ldapTLS = false;
$this->configuration->ldapTLS = (string)false;
$this->logger->info(
'LDAPS (already using secure connection) and TLS do not work together. Switched off TLS.',
['app' => 'user_ldap']
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Group_Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function setup(): void {
$this->backends[$configPrefix] =
new Group_LDAP($this->getAccess($configPrefix), $this->groupPluginManager, $this->config, $this->ncUserManager);
if (is_null($this->refBackend)) {
$this->refBackend = &$this->backends[$configPrefix];
$this->refBackend = $this->backends[$configPrefix];
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Jobs/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function runCycle($cycleData) {
$results = $access->fetchListOfUsers(
$filter,
$access->userManager->getAttributes(),
$connection->ldapPagingSize,
(int)$connection->ldapPagingSize,
$cycleData['offset'],
true
);
Expand Down
1 change: 1 addition & 0 deletions apps/user_ldap/lib/LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit =
$serverControls = [];
}

/** @psalm-suppress UndefinedVariable $oldHandler is defined when the closure is called but psalm fails to get that */
$oldHandler = set_error_handler(function ($no, $message, $file, $line) use (&$oldHandler) {
if (str_contains($message, 'Partial search results returned: Sizelimit exceeded')) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/User_Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function setup(): void {
);

if (is_null($this->refBackend)) {
$this->refBackend = &$this->backends[$configPrefix];
$this->refBackend = $this->backends[$configPrefix];
}
}

Expand Down
16 changes: 11 additions & 5 deletions apps/user_ldap/lib/Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ private function determineGroups(string $dbKey, string $confKey, bool $testMembe
$this->fetchGroups($dbKey, $confKey);

if ($testMemberOf) {
$this->configuration->hasMemberOfFilterSupport = $this->testMemberOf();
$this->configuration->hasMemberOfFilterSupport = (string)$this->testMemberOf();
$this->result->markChange();
if (!$this->configuration->hasMemberOfFilterSupport) {
throw new \Exception('memberOf is not supported by the server');
Expand Down Expand Up @@ -700,8 +700,8 @@ public function guessPortAndTLS() {

if ($settingsFound === true) {
$config = [
'ldapPort' => $p,
'ldapTLS' => (int)$t
'ldapPort' => (string)$p,
'ldapTLS' => (string)$t,
];
$this->configuration->setConfiguration($config);
$this->logger->debug(
Expand Down Expand Up @@ -1322,7 +1322,7 @@ private function getConnection(): \LDAP\Connection|false {
$this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3);
$this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0);
$this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT);
if ($this->configuration->ldapTLS === 1) {
if ($this->configuration->ldapTLS) {
$this->ldap->startTls($cr);
}

Expand All @@ -1337,6 +1337,9 @@ private function getConnection(): \LDAP\Connection|false {
return false;
}

/**
* @return array<array{port:int,tls:bool}>
*/
private function getDefaultLdapPortSettings(): array {
static $settings = [
['port' => 7636, 'tls' => false],
Expand All @@ -1349,6 +1352,9 @@ private function getDefaultLdapPortSettings(): array {
return $settings;
}

/**
* @return array<array{port:int,tls:bool}>
*/
private function getPortSettingsToTry(): array {
//389 ← LDAP / Unencrypted or StartTLS
//636 ← LDAPS / SSL
Expand All @@ -1367,7 +1373,7 @@ private function getPortSettingsToTry(): array {
}
$portSettings[] = ['port' => $port, 'tls' => false];
} elseif ($this->configuration->usesLdapi()) {
$portSettings[] = ['port' => '', 'tls' => false];
$portSettings[] = ['port' => 0, 'tls' => false];
}

//default ports
Expand Down
Loading
Loading