-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
refactor(encryption): Migrate appconfig keys to typed bool IAppConfig with repair step #60002
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
base: master
Are you sure you want to change the base?
Changes from all commits
38c3eb7
a088ddf
e292a0f
1bd6790
70a9b44
1db5b05
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 |
|---|---|---|
|
|
@@ -1300,10 +1300,8 @@ | |
| </file> | ||
| <file src="apps/encryption/lib/Util.php"> | ||
| <DeprecatedMethod> | ||
| <code><![CDATA[getAppValue]]></code> | ||
| <code><![CDATA[getAppValue]]></code> | ||
| <code><![CDATA[getUserValue]]></code> | ||
| <code><![CDATA[setAppValue]]></code> | ||
| <code><![CDATA[setUserValue]]></code> | ||
|
Comment on lines
-1303
to
1305
Member
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. All of these should be migrated |
||
| </DeprecatedMethod> | ||
| <InternalMethod> | ||
|
|
@@ -3017,19 +3015,6 @@ | |
| <code><![CDATA[\OC_Util::tearDownFS()]]></code> | ||
| </DeprecatedMethod> | ||
| </file> | ||
| <file src="core/Command/Encryption/Disable.php"> | ||
| <DeprecatedMethod> | ||
| <code><![CDATA[getAppValue]]></code> | ||
| <code><![CDATA[setAppValue]]></code> | ||
| </DeprecatedMethod> | ||
| </file> | ||
| <file src="core/Command/Encryption/Enable.php"> | ||
| <DeprecatedMethod> | ||
| <code><![CDATA[getAppValue]]></code> | ||
| <code><![CDATA[getAppValue]]></code> | ||
| <code><![CDATA[setAppValue]]></code> | ||
| </DeprecatedMethod> | ||
| </file> | ||
| <file src="core/Command/Encryption/MigrateKeyStorage.php"> | ||
| <DeprecatedClass> | ||
| <code><![CDATA[\OC_Util::setupFS($uid)]]></code> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
| return 1; | ||
| } | ||
|
|
||
| $originallyEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled'); | ||
| $originallyEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled', false); | ||
|
Member
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. Unnecessary change, since the default is already false. |
||
| try { | ||
| if ($originallyEnabled) { | ||
| $output->write('Disable server side encryption... '); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,14 +10,14 @@ | |||||
| namespace OC\Core\Command\Encryption; | ||||||
|
|
||||||
| use OCP\Encryption\IManager; | ||||||
| use OCP\IConfig; | ||||||
| use OCP\IAppConfig; | ||||||
| use Symfony\Component\Console\Command\Command; | ||||||
| use Symfony\Component\Console\Input\InputInterface; | ||||||
| use Symfony\Component\Console\Output\OutputInterface; | ||||||
|
|
||||||
| class Enable extends Command { | ||||||
| public function __construct( | ||||||
| protected IConfig $config, | ||||||
| protected IAppConfig $appConfig, | ||||||
| protected IManager $encryptionManager, | ||||||
| ) { | ||||||
| parent::__construct(); | ||||||
|
|
@@ -33,10 +33,11 @@ protected function configure() { | |||||
|
|
||||||
| #[\Override] | ||||||
| protected function execute(InputInterface $input, OutputInterface $output): int { | ||||||
| if ($this->config->getAppValue('core', 'encryption_enabled', 'no') === 'yes') { | ||||||
| $isEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled', false); | ||||||
|
Member
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.
Suggested change
Also unnecessary default value. |
||||||
| if ($isEnabled) { | ||||||
| $output->writeln('Encryption is already enabled'); | ||||||
| } else { | ||||||
| $this->config->setAppValue('core', 'encryption_enabled', 'yes'); | ||||||
| $this->appConfig->setValueBool('core', 'encryption_enabled', true); | ||||||
| $output->writeln('<info>Encryption enabled</info>'); | ||||||
| } | ||||||
| $output->writeln(''); | ||||||
|
|
@@ -46,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |||||
| $output->writeln('<error>No encryption module is loaded</error>'); | ||||||
| return 1; | ||||||
| } | ||||||
| $defaultModule = $this->config->getAppValue('core', 'default_encryption_module'); | ||||||
| $defaultModule = $this->appConfig->getValueString('core', 'default_encryption_module', ''); | ||||||
|
Member
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.
Suggested change
Already the default. |
||||||
| if ($defaultModule === '') { | ||||||
| $output->writeln('<error>No default module is set</error>'); | ||||||
| return 1; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |||||
| use OCP\Files\Storage\IStorage; | ||||||
| use OCP\IConfig; | ||||||
| use OCP\IL10N; | ||||||
| use OCP\Server; | ||||||
| use Psr\Log\LoggerInterface; | ||||||
|
|
||||||
| class Manager implements IManager { | ||||||
|
|
@@ -48,8 +49,12 @@ public function isEnabled() { | |||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| $enabled = $this->config->getAppValue('core', 'encryption_enabled', 'no'); | ||||||
| return $enabled === 'yes'; | ||||||
| try { | ||||||
| return Server::get(\OCP\IAppConfig::class)->getValueBool('core', 'encryption_enabled', false); | ||||||
|
Member
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. It's better if you inject IAppConfig into this class.
Member
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.
Suggested change
|
||||||
| } catch (\Throwable) { | ||||||
| // DB not ready (e.g. oc_appconfig does not yet exist during install). | ||||||
| return false; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
||||||
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.
This should also be migrated to
getValueBool