Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
eb1d612
Add api to register setup checks
CarlSchwan May 23, 2022
c71e47f
Progress
CarlSchwan May 30, 2022
0890012
Fix SetupChecks/LdapInvalidUuids.php
come-nc Sep 28, 2023
a3ec716
Fix UI and add PhpOutdated check
come-nc Sep 28, 2023
1202171
Fix docblock and types for new public API
come-nc Sep 28, 2023
b41b9cf
Small cleanups in SetupCheck classes
come-nc Sep 28, 2023
a56d40c
Fix lint problems in vue files
come-nc Sep 28, 2023
a4618cf
Move existing setup checks to new API
come-nc Oct 2, 2023
67e7a26
Fix PHPDoc in OCP for new SetupResult class
come-nc Oct 2, 2023
8bfa093
Migrate NeedsSystemAddressBookSync to new ISetupCheck API
come-nc Oct 2, 2023
bec6c0a
Migrate ReadOnlyConfig and DefaultPhoneRegionSet to new API
come-nc Oct 2, 2023
fa3c0e4
Fix description for SetupChecks/NeedsSystemAddressBookSync
come-nc Oct 9, 2023
05cb141
Merge setupchecks from new API into old UI
come-nc Oct 9, 2023
5503c4c
Add missing licences and copyright in SetupCheck
come-nc Oct 9, 2023
bd37067
Migrate InternetConnectivity check to new API
come-nc Oct 9, 2023
efa2dfa
Add OCP interface for SetupCheckManager
come-nc Oct 9, 2023
6bc3e00
Fix tests for setup checks
come-nc Oct 9, 2023
968b82c
Remove UI draft
come-nc Oct 12, 2023
be11ffd
Add debug logging when running setup checks to help with debugging sl…
come-nc Oct 16, 2023
6aa6f26
Move NeedsSystemAddressBookSync to dav application where it’s registered
come-nc Oct 16, 2023
11ebf46
Remove useless var in apps/settings/lib/SetupChecks/CheckUserCertific…
come-nc Oct 16, 2023
2e4d154
Change SetupResult API to named constructors
come-nc Oct 16, 2023
a3cc3b1
Small code style fix in SetupCheckManager
come-nc Oct 19, 2023
789ff3f
Fix jsunit tests for SetupChecks
come-nc Oct 19, 2023
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
Prev Previous commit
Next Next commit
Progress
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan authored and come-nc committed Oct 19, 2023
commit c71e47f5c311836973c7ae22b174dfbbf8117304
2 changes: 2 additions & 0 deletions apps/settings/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use OCA\Settings\Search\SectionSearch;
use OCA\Settings\Search\UserSearch;
use OCA\Settings\SetupChecks\CheckUserCertificates;
use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
use OCA\Settings\UserMigration\AccountMigrator;
use OCA\Settings\WellKnown\ChangePasswordHandler;
use OCA\Settings\WellKnown\SecurityTxtHandler;
Expand Down Expand Up @@ -139,6 +140,7 @@ public function register(IRegistrationContext $context): void {
);
});
$context->registerSetupCheck(CheckUserCertificates::class);
$context->registerSetupCheck(LegacySSEKeyFormat::class);

$context->registerUserMigrator(AccountMigrator::class);
}
Expand Down
7 changes: 0 additions & 7 deletions apps/settings/lib/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
use OC\MemoryInfo;
use OCA\Settings\SetupChecks\CheckUserCertificates;
use OCA\Settings\SetupChecks\NeedsSystemAddressBookSync;
use OCA\Settings\SetupChecks\LdapInvalidUuids;
use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
use OCA\Settings\SetupChecks\PhpDefaultCharset;
use OCA\Settings\SetupChecks\PhpOutputBuffering;
Expand Down Expand Up @@ -920,10 +919,7 @@ protected function imageMagickLacksSVGSupport(): bool {
public function check() {
$phpDefaultCharset = new PhpDefaultCharset();
$phpOutputBuffering = new PhpOutputBuffering();
$legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
//$checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator);
$supportedDatabases = new SupportedDatabase($this->l10n, $this->connection);
$ldapInvalidUuids = new LdapInvalidUuids($this->appManager, $this->l10n, $this->serverContainer);
$needsSystemAddressBookSync = new NeedsSystemAddressBookSync($this->config, $this->l10n);

return new DataResponse(
Expand Down Expand Up @@ -974,12 +970,9 @@ public function check() {
'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(),
PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()],
PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()],
LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()],
//CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()],
'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '',
SupportedDatabase::class => ['pass' => $supportedDatabases->run(), 'description' => $supportedDatabases->description(), 'severity' => $supportedDatabases->severity()],
'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(),
LdapInvalidUuids::class => ['pass' => $ldapInvalidUuids->run(), 'description' => $ldapInvalidUuids->description(), 'severity' => $ldapInvalidUuids->severity()],
NeedsSystemAddressBookSync::class => ['pass' => $needsSystemAddressBookSync->run(), 'description' => $needsSystemAddressBookSync->description(), 'severity' => $needsSystemAddressBookSync->severity()],
]
);
Expand Down
32 changes: 15 additions & 17 deletions apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,32 @@
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;

class LegacySSEKeyFormat {
/** @var IL10N */
private $l10n;
/** @var IConfig */
private $config;
/** @var IURLGenerator */
private $urlGenerator;
class LegacySSEKeyFormat implements ISetupCheck {
private IL10N $l10n;
private IConfig $config;
private IURLGenerator $urlGenerator;

public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) {
$this->l10n = $l10n;
$this->config = $config;
$this->urlGenerator = $urlGenerator;
}

public function description(): string {
return $this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.');
public function getCategory(): string {
return 'security';
}

public function severity(): string {
return 'warning';
public function getName(): string {
return $this->l10n->t('Checking for old server-side-encryption being disabled');
}

public function run(): bool {
return $this->config->getSystemValueBool('encryption.legacy_format_support', false) === false;
}

public function linkToDocumentation(): string {
return $this->urlGenerator->linkToDocs('admin-sse-legacy-format');
public function run(): SetupResult {
if ($this->config->getSystemValueBool('encryption.legacy_format_support', false) === false) {
return new SetupResult(SetupResult::SUCCESS);
}
return new SetupResult(SetupResult::WARNING, $this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.'), $this->urlGenerator->linkToDocs('admin-sse-legacy-format'));
}
}
78 changes: 67 additions & 11 deletions apps/settings/src/components/SetupCheck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@
:description="t('settings', `It's important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the linked documentation for more information.`)">
<div v-for="(checks, category) in results"
:key="category"
class="card">
<div class="card__header">
class="check-card">
<div class="check-card__header" @click="toggleCollapse(category)">
<h3>{{ category }}</h3>
<Check v-if="stats[category].successes === stats[category].total"
:size="20"
:fill-color="'var(--color-success)'" />
<Check v-else-if="stats[category].errors > 0"
:size="20"
:fill-color="'var(--color-error)'" />
<Check v-else-if="stats[category].warnings > 0"
:size="20"
:fill-color="'var(--color-warning)'" />
<span>
{{ stats[category].successes }} / {{ stats[category].total }}
</span>
</div>
<div class="card__body">
<div v-for="(check, name) in checks" :key="name" class="check">
<div class="card__body" v-if="!collapsed[category]">
<div v-for="(check, name) in checks" :key="name" class="row-check" :class="['row-check__' + check.severity]">
<template v-if="check.severity === 'success'">
<Check :size="20" :fill-color="'var(--color-success)'" />
</template>
Expand All @@ -34,31 +46,75 @@ export default {
data() {
return {
results: [],
collapsed: {},
stats: {},
}
},
mounted() {
this.loadSetupChecks()
},
methods: {
toggleCollapse(category) {
this.collapsed[category] = !this.collapsed[category]
},
async loadSetupChecks() {
const { data } = await axios.get(generateUrl('/settings/setupcheck'))
console.debug(data)
const collapsed = {}
const stats = {}
for (const [category, checks] of Object.entries(data)) {
const values = Object.values(checks)
stats[category] = {
total: values.length,
successes: values.filter((check) => check.severity === 'success').length,
warnings: values.filter((check) => check.severity === 'warning').length,
errors: values.filter((check) => check.severity === 'errors').length,
}
collapsed[category] = stats[category].errors > 0
}
this.collapsed = collapsed
this.stats = stats
this.results = data
},
},
}
</script>

<style lang="scss" scoped>
.card {
box-shadow: 0 4px 8px 0 rgba(var(--color-box-shadow-rgb), 0.4);
.check-card {
border: 1px solid var(--color-border);
border-radius: var(--border-radius);
&__body, &__header {
padding: 4px 8px;
}
.check {
&__header {
padding: 0.5rem 1rem;
display: flex;
align-items: center;
h3 {
margin: 0;
}
.material-design-icon {
margin-left: auto;
margin-right: 0.5rem;
}
}
}
.row-check {
color: var(--color-text-light);
background-color: var(--note-background);
box-shadow: rgba(43, 42, 51, 0.05) 0 1px 2px 0;
margin: 0;
padding: 0.5rem 1rem;
display: flex;
align-items: center;
&__success {
--note-background: rgba(var(--color-success-rgb), 0.2);
--note-theme: var(--color-success);
}
&__error {
--note-background: rgba(var(--color-error-rgb), 0.2);
--note-theme: var(--color-error);
}
&__warning {
--note-background: rgba(var(--color-warning-rgb), 0.2);
--note-theme: var(--color-warning);
}
}
</style>
1 change: 1 addition & 0 deletions apps/user_ldap/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
'OCA\\User_LDAP\\Service\\UpdateGroupsService' => $baseDir . '/../lib/Service/UpdateGroupsService.php',
'OCA\\User_LDAP\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
'OCA\\User_LDAP\\Settings\\Section' => $baseDir . '/../lib/Settings/Section.php',
'OCA\\User_LDAP\\SetupChecks\\LdapInvalidUuids' => $baseDir . '/../lib/SetupChecks/LdapInvalidUuids.php',
'OCA\\User_LDAP\\UserPluginManager' => $baseDir . '/../lib/UserPluginManager.php',
'OCA\\User_LDAP\\User\\DeletedUsersIndex' => $baseDir . '/../lib/User/DeletedUsersIndex.php',
'OCA\\User_LDAP\\User\\Manager' => $baseDir . '/../lib/User/Manager.php',
Expand Down
1 change: 1 addition & 0 deletions apps/user_ldap/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class ComposerStaticInitUser_LDAP
'OCA\\User_LDAP\\Service\\UpdateGroupsService' => __DIR__ . '/..' . '/../lib/Service/UpdateGroupsService.php',
'OCA\\User_LDAP\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
'OCA\\User_LDAP\\Settings\\Section' => __DIR__ . '/..' . '/../lib/Settings/Section.php',
'OCA\\User_LDAP\\SetupChecks\\LdapInvalidUuids' => __DIR__ . '/..' . '/../lib/SetupChecks/LdapInvalidUuids.php',
'OCA\\User_LDAP\\UserPluginManager' => __DIR__ . '/..' . '/../lib/UserPluginManager.php',
'OCA\\User_LDAP\\User\\DeletedUsersIndex' => __DIR__ . '/..' . '/../lib/User/DeletedUsersIndex.php',
'OCA\\User_LDAP\\User\\Manager' => __DIR__ . '/..' . '/../lib/User/Manager.php',
Expand Down
2 changes: 2 additions & 0 deletions apps/user_ldap/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\User_Proxy;
use OCA\User_LDAP\UserPluginManager;
use OCA\User_LDAP\SetupChecks\LdapInvalidUuids;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
Expand Down Expand Up @@ -116,6 +117,7 @@ function (ContainerInterface $c) {
false
);
$context->registerEventListener(PostLoginEvent::class, LoginListener::class);
$context->registerSetupCheck(LdapInvalidUuids::class);
}

public function boot(IBootContext $context): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,29 @@
*
*/

namespace OCA\Settings\SetupChecks;
namespace OCA\User_LDAP\SetupChecks;

use OCA\User_LDAP\Mapping\GroupMapping;
use OCA\User_LDAP\Mapping\UserMapping;
use OCP\App\IAppManager;
use OCP\IL10N;
use OCP\IServerContainer;
use OCP\SetupCheck\ISetupCheck;

class LdapInvalidUuids {
class LdapInvalidUuids implements ISetupCheck {
private IL10N $l10n;
private IServerContainer $server;
private UserMapping $userMapping;
private GroupMapping $groupMapping;

/** @var IAppManager */
private $appManager;
/** @var IL10N */
private $l10n;
/** @var IServerContainer */
private $server;

public function __construct(IAppManager $appManager, IL10N $l10n, IServerContainer $server) {
$this->appManager = $appManager;
public function __construct(IL10N $l10n, UserMapping $userMapping, GroupMapping $groupMapping) {
$this->l10n = $l10n;
$this->server = $server;
$this->userMapping = $userMapping;
$this->groupMapping = $groupMapping;
}

public function getCategory(): string {
return 'ldap';
}

public function description(): string {
Expand All @@ -56,14 +58,7 @@ public function severity(): string {
}

public function run(): bool {
if (!$this->appManager->isEnabledForUser('user_ldap')) {
return true;
}
/** @var UserMapping $userMapping */
$userMapping = $this->server->get(UserMapping::class);
/** @var GroupMapping $groupMapping */
$groupMapping = $this->server->get(GroupMapping::class);
return count($userMapping->getList(0, 1, true)) === 0
&& count($groupMapping->getList(0, 1, true)) === 0;
return count($this->userMapping->getList(0, 1, true)) === 0
&& count($this->groupMapping->getList(0, 1, true)) === 0;
}
}
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,7 @@
'OC\\Settings\\Manager' => $baseDir . '/lib/private/Settings/Manager.php',
'OC\\Settings\\Section' => $baseDir . '/lib/private/Settings/Section.php',
'OC\\Setup' => $baseDir . '/lib/private/Setup.php',
'OC\\SetupCheck\\SetupCheckManager' => $baseDir . '/lib/private/SetupCheck/SetupCheckManager.php',
'OC\\Setup\\AbstractDatabase' => $baseDir . '/lib/private/Setup/AbstractDatabase.php',
'OC\\Setup\\MySQL' => $baseDir . '/lib/private/Setup/MySQL.php',
'OC\\Setup\\OCI' => $baseDir . '/lib/private/Setup/OCI.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Settings\\Manager' => __DIR__ . '/../../..' . '/lib/private/Settings/Manager.php',
'OC\\Settings\\Section' => __DIR__ . '/../../..' . '/lib/private/Settings/Section.php',
'OC\\Setup' => __DIR__ . '/../../..' . '/lib/private/Setup.php',
'OC\\SetupCheck\\SetupCheckManager' => __DIR__ . '/../../..' . '/lib/private/SetupCheck/SetupCheckManager.php',
'OC\\Setup\\AbstractDatabase' => __DIR__ . '/../../..' . '/lib/private/Setup/AbstractDatabase.php',
'OC\\Setup\\MySQL' => __DIR__ . '/../../..' . '/lib/private/Setup/MySQL.php',
'OC\\Setup\\OCI' => __DIR__ . '/../../..' . '/lib/private/Setup/OCI.php',
Expand Down
5 changes: 5 additions & 0 deletions lib/public/SetupCheck/ISetupCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ interface ISetupCheck {
*/
public function getCategory(): string;

/**
* @since 25.0.0
*/
public function getName(): string;

/**
* @since 25.0.0
*/
Expand Down