diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-04-30 16:14:10 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-07-07 11:18:24 +0200 |
commit | 2f653320146ebdd840176c74d9ffdaaf435e1f2f (patch) | |
tree | a2e11a9de5e025af21e4a1adb5e0ceb054474205 /core/command | |
parent | 6763637773f5b9f2993f65427be21ee04f192ea1 (diff) | |
download | nextcloud-server-2f653320146ebdd840176c74d9ffdaaf435e1f2f.tar.gz nextcloud-server-2f653320146ebdd840176c74d9ffdaaf435e1f2f.zip |
Add an option to exclude sensitive values (e.g. for reports)
Diffstat (limited to 'core/command')
-rw-r--r-- | core/command/config/listconfigs.php | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/core/command/config/listconfigs.php b/core/command/config/listconfigs.php index d25495a55d1..5b9bca20f03 100644 --- a/core/command/config/listconfigs.php +++ b/core/command/config/listconfigs.php @@ -26,9 +26,20 @@ use OC\SystemConfig; use OCP\IAppConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ListConfigs extends Base { + /** @var array */ + protected $sensitiveValues = [ + 'dbpassword', + 'dbuser', + 'mail_smtpname', + 'mail_smtppassword', + 'passwordsalt', + 'secret', + ]; + /** * @var SystemConfig */ protected $systemConfig; @@ -55,16 +66,29 @@ class ListConfigs extends Base { 'app', InputArgument::OPTIONAL, 'Name of the app ("system" to get the config.php values, "all" for all apps and system)', - 'system' + 'all' + ) + ->addOption( + 'public', + null, + InputOption::VALUE_NONE, + 'Use this option when you want to exclude sensitive configs like passwords, salts, ...' ) ; } protected function execute(InputInterface $input, OutputInterface $output) { $app = $input->getArgument('app'); + $noSensitiveValues = $input->getOption('public'); + + if ($noSensitiveValues && !$input->hasParameterOption('--output')) { + // If you post this publicly we prefer the json format + $input->setOption('output', 'json_pretty'); + } + switch ($app) { case 'system': - $configs = $this->getSystemConfigs(); + $configs = $this->getSystemConfigs($noSensitiveValues); break; case 'all': @@ -73,7 +97,7 @@ class ListConfigs extends Base { foreach ($apps as $appName) { $configs[$appName] = $this->appConfig->getValues($appName, false); } - $configs['system'] = $this->getSystemConfigs(); + $configs['system'] = $this->getSystemConfigs($noSensitiveValues); break; default: @@ -85,13 +109,19 @@ class ListConfigs extends Base { /** * Get the system configs + * + * @param bool $noSensitiveValues * @return array */ - protected function getSystemConfigs() { + protected function getSystemConfigs($noSensitiveValues) { $keys = $this->systemConfig->getKeys(); $configs = []; foreach ($keys as $key) { + if ($noSensitiveValues && in_array($key, $this->sensitiveValues)) { + continue; + } + $value = $this->systemConfig->getValue($key, new \Exception('Not set')); if (!($value instanceof \Exception)) { $configs[$key] = $value; |