Don't perform checks for outdated TLS libs when no internet connection

This change makes the check return a positive result when:

- The instance has been configured to not use the internet
AND/OR
- S2S AND the appstore is disabled
This commit is contained in:
Lukas Reschke 2015-10-08 18:23:20 +02:00
parent 9b220d0576
commit 12181aa6de
2 changed files with 125 additions and 15 deletions

View File

@ -123,7 +123,7 @@ class CheckSetupController extends Controller {
* *
* @return array * @return array
*/ */
public function getCurlVersion() { protected function getCurlVersion() {
return curl_version(); return curl_version();
} }
@ -137,6 +137,24 @@ class CheckSetupController extends Controller {
* @return string * @return string
*/ */
private function isUsedTlsLibOutdated() { private function isUsedTlsLibOutdated() {
// Appstore is disabled by default in EE
$appStoreDefault = false;
if (\OC_Util::getEditionString() === '') {
$appStoreDefault = true;
}
// Don't run check when:
// 1. Server has `has_internet_connection` set to false
// 2. AppStore AND S2S is disabled
if(!$this->config->getSystemValue('has_internet_connection', true)) {
return '';
}
if(!$this->config->getSystemValue('appstoreenabled', $appStoreDefault)
&& $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
&& $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
return '';
}
$versionString = $this->getCurlVersion(); $versionString = $this->getCurlVersion();
if(isset($versionString['ssl_version'])) { if(isset($versionString['ssl_version'])) {
$versionString = $versionString['ssl_version']; $versionString = $versionString['ssl_version'];
@ -145,7 +163,7 @@ class CheckSetupController extends Controller {
} }
$features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
if(!$this->config->getSystemValue('appstoreenabled', true)) { if(!$this->config->getSystemValue('appstoreenabled', $appStoreDefault)) {
$features = (string)$this->l10n->t('Federated Cloud Sharing'); $features = (string)$this->l10n->t('Federated Cloud Sharing');
} }

View File

@ -292,6 +292,10 @@ class CheckSetupControllerTest extends TestCase {
->with('memcache.local', null) ->with('memcache.local', null)
->will($this->returnValue('SomeProvider')); ->will($this->returnValue('SomeProvider'));
$this->config->expects($this->at(2)) $this->config->expects($this->at(2))
->method('getSystemValue')
->with('has_internet_connection', true)
->will($this->returnValue(false));
$this->config->expects($this->at(3))
->method('getSystemValue') ->method('getSystemValue')
->with('trusted_proxies', []) ->with('trusted_proxies', [])
->willReturn(['1.2.3.4']); ->willReturn(['1.2.3.4']);
@ -365,10 +369,13 @@ class CheckSetupControllerTest extends TestCase {
]) ])
->setMethods(null)->getMock(); ->setMethods(null)->getMock();
$this->assertArrayHasKey('ssl_version', $checkSetupController->getCurlVersion()); $this->assertArrayHasKey('ssl_version', $this->invokePrivate($checkSetupController, 'getCurlVersion'));
} }
public function testIsUsedTlsLibOutdatedWithAnotherLibrary() { public function testIsUsedTlsLibOutdatedWithAnotherLibrary() {
$this->config->expects($this->any())
->method('getSystemValue')
->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
->method('getCurlVersion') ->method('getCurlVersion')
@ -377,6 +384,9 @@ class CheckSetupControllerTest extends TestCase {
} }
public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() { public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() {
$this->config->expects($this->any())
->method('getSystemValue')
->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
->method('getCurlVersion') ->method('getCurlVersion')
@ -385,10 +395,8 @@ class CheckSetupControllerTest extends TestCase {
} }
public function testIsUsedTlsLibOutdatedWithOlderOpenSsl() { public function testIsUsedTlsLibOutdatedWithOlderOpenSsl() {
$this->config $this->config->expects($this->any())
->expects($this->once())
->method('getSystemValue') ->method('getSystemValue')
->with('appstoreenabled', true)
->will($this->returnValue(true)); ->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
@ -399,10 +407,10 @@ class CheckSetupControllerTest extends TestCase {
public function testIsUsedTlsLibOutdatedWithOlderOpenSslAndWithoutAppstore() { public function testIsUsedTlsLibOutdatedWithOlderOpenSslAndWithoutAppstore() {
$this->config $this->config
->expects($this->once()) ->expects($this->at(0))
->method('getSystemValue') ->method('getSystemValue')
->with('appstoreenabled', true) ->with('has_internet_connection', true)
->will($this->returnValue(false)); ->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
->method('getCurlVersion') ->method('getCurlVersion')
@ -411,10 +419,8 @@ class CheckSetupControllerTest extends TestCase {
} }
public function testIsUsedTlsLibOutdatedWithOlderOpenSsl1() { public function testIsUsedTlsLibOutdatedWithOlderOpenSsl1() {
$this->config $this->config->expects($this->any())
->expects($this->once())
->method('getSystemValue') ->method('getSystemValue')
->with('appstoreenabled', true)
->will($this->returnValue(true)); ->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
@ -424,6 +430,9 @@ class CheckSetupControllerTest extends TestCase {
} }
public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion() { public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion() {
$this->config->expects($this->any())
->method('getSystemValue')
->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
->method('getCurlVersion') ->method('getCurlVersion')
@ -432,6 +441,9 @@ class CheckSetupControllerTest extends TestCase {
} }
public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion1() { public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion1() {
$this->config->expects($this->any())
->method('getSystemValue')
->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
->method('getCurlVersion') ->method('getCurlVersion')
@ -440,10 +452,8 @@ class CheckSetupControllerTest extends TestCase {
} }
public function testIsBuggyNss400() { public function testIsBuggyNss400() {
$this->config $this->config->expects($this->any())
->expects($this->once())
->method('getSystemValue') ->method('getSystemValue')
->with('appstoreenabled', true)
->will($this->returnValue(true)); ->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
@ -476,6 +486,9 @@ class CheckSetupControllerTest extends TestCase {
public function testIsBuggyNss200() { public function testIsBuggyNss200() {
$this->config->expects($this->any())
->method('getSystemValue')
->will($this->returnValue(true));
$this->checkSetupController $this->checkSetupController
->expects($this->once()) ->expects($this->once())
->method('getCurlVersion') ->method('getCurlVersion')
@ -504,4 +517,83 @@ class CheckSetupControllerTest extends TestCase {
$this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated')); $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
} }
public function testIsUsedTlsLibOutdatedWithInternetDisabled() {
$this->config
->expects($this->at(0))
->method('getSystemValue')
->with('has_internet_connection', true)
->will($this->returnValue(false));
$this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
}
public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingEnabled() {
// Appstore is disabled by default in EE
$appStoreDefault = false;
if (\OC_Util::getEditionString() === '') {
$appStoreDefault = true;
}
$this->config
->expects($this->at(0))
->method('getSystemValue')
->with('has_internet_connection', true)
->will($this->returnValue(true));
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('appstoreenabled', $appStoreDefault)
->will($this->returnValue(false));
$this->config
->expects($this->at(2))
->method('getAppValue')
->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
->will($this->returnValue('no'));
$this->config
->expects($this->at(3))
->method('getAppValue')
->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
->will($this->returnValue('yes'));
$this->checkSetupController
->expects($this->once())
->method('getCurlVersion')
->will($this->returnValue([]));
$this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
}
public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingDisabled() {
// Appstore is disabled by default in EE
$appStoreDefault = false;
if (\OC_Util::getEditionString() === '') {
$appStoreDefault = true;
}
$this->config
->expects($this->at(0))
->method('getSystemValue')
->with('has_internet_connection', true)
->will($this->returnValue(true));
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('appstoreenabled', $appStoreDefault)
->will($this->returnValue(false));
$this->config
->expects($this->at(2))
->method('getAppValue')
->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
->will($this->returnValue('no'));
$this->config
->expects($this->at(3))
->method('getAppValue')
->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
->will($this->returnValue('no'));
$this->checkSetupController
->expects($this->never())
->method('getCurlVersion')
->will($this->returnValue([]));
$this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
}
} }