mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Add a "Config" plugin to DarkConsole.
Summary: This plugin lets you see how the host is configured at runtime. Test Plan: Reviewers: CC:
This commit is contained in:
parent
bacf622178
commit
3b7d73c41b
5 changed files with 87 additions and 0 deletions
|
@ -90,6 +90,16 @@ return array(
|
||||||
'darkconsole.always-on' => false,
|
'darkconsole.always-on' => false,
|
||||||
|
|
||||||
|
|
||||||
|
// Allows you to mask certain configuration values from appearing in the
|
||||||
|
// "Config" tab of DarkConsole.
|
||||||
|
'darkconsole.config-mask' => array(
|
||||||
|
'mysql.pass',
|
||||||
|
'amazon-ses.secret-key',
|
||||||
|
'recaptcha.private-key',
|
||||||
|
'phabricator.csrf-key',
|
||||||
|
'facebook.application-secret',
|
||||||
|
),
|
||||||
|
|
||||||
// -- MySQL --------------------------------------------------------------- //
|
// -- MySQL --------------------------------------------------------------- //
|
||||||
|
|
||||||
// The username to use when connecting to MySQL.
|
// The username to use when connecting to MySQL.
|
||||||
|
|
|
@ -76,6 +76,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find',
|
'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find',
|
||||||
'ConduitException' => 'applications/conduit/protocol/exception',
|
'ConduitException' => 'applications/conduit/protocol/exception',
|
||||||
'DarkConsole' => 'aphront/console/api',
|
'DarkConsole' => 'aphront/console/api',
|
||||||
|
'DarkConsoleConfigPlugin' => 'aphront/console/plugin/config',
|
||||||
'DarkConsoleController' => 'aphront/console/controller',
|
'DarkConsoleController' => 'aphront/console/controller',
|
||||||
'DarkConsoleCore' => 'aphront/console/core',
|
'DarkConsoleCore' => 'aphront/console/core',
|
||||||
'DarkConsoleErrorLogPlugin' => 'aphront/console/plugin/errorlog',
|
'DarkConsoleErrorLogPlugin' => 'aphront/console/plugin/errorlog',
|
||||||
|
@ -304,6 +305,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
||||||
|
'DarkConsoleConfigPlugin' => 'DarkConsolePlugin',
|
||||||
'DarkConsoleController' => 'PhabricatorController',
|
'DarkConsoleController' => 'PhabricatorController',
|
||||||
'DarkConsoleErrorLogPlugin' => 'DarkConsolePlugin',
|
'DarkConsoleErrorLogPlugin' => 'DarkConsolePlugin',
|
||||||
'DarkConsoleRequestPlugin' => 'DarkConsolePlugin',
|
'DarkConsoleRequestPlugin' => 'DarkConsolePlugin',
|
||||||
|
|
|
@ -22,6 +22,7 @@ final class DarkConsoleCore {
|
||||||
const PLUGIN_SERVICES = 'Services';
|
const PLUGIN_SERVICES = 'Services';
|
||||||
const PLUGIN_XHPROF = 'XHProf';
|
const PLUGIN_XHPROF = 'XHProf';
|
||||||
const PLUGIN_REQUEST = 'Request';
|
const PLUGIN_REQUEST = 'Request';
|
||||||
|
const PLUGIN_CONFIG = 'Config';
|
||||||
|
|
||||||
public static function getPlugins() {
|
public static function getPlugins() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -29,6 +30,7 @@ final class DarkConsoleCore {
|
||||||
self::PLUGIN_REQUEST,
|
self::PLUGIN_REQUEST,
|
||||||
self::PLUGIN_SERVICES,
|
self::PLUGIN_SERVICES,
|
||||||
self::PLUGIN_XHPROF,
|
self::PLUGIN_XHPROF,
|
||||||
|
self::PLUGIN_CONFIG,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
69
src/aphront/console/plugin/config/DarkConsoleConfigPlugin.php
Executable file
69
src/aphront/console/plugin/config/DarkConsoleConfigPlugin.php
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DarkConsoleConfigPlugin extends DarkConsolePlugin {
|
||||||
|
|
||||||
|
public function getName() {
|
||||||
|
return 'Config';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription() {
|
||||||
|
return 'Information about Phabricator configuration';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateData() {
|
||||||
|
return PhabricatorEnv::getAllConfigKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
|
||||||
|
$data = $this->getData();
|
||||||
|
ksort($data);
|
||||||
|
|
||||||
|
$mask = PhabricatorEnv::getEnvConfig('darkconsole.config-mask');
|
||||||
|
$mask = array_fill_keys($mask, true);
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
if (empty($mask[$key])) {
|
||||||
|
$display_value = is_array($value) ? json_encode($value) : $value;
|
||||||
|
$display_value = phutil_escape_html($display_value);
|
||||||
|
} else {
|
||||||
|
$display_value = phutil_escape_html('<Masked>');
|
||||||
|
}
|
||||||
|
$rows[] = array(
|
||||||
|
phutil_escape_html($key),
|
||||||
|
$display_value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table = new AphrontTableView($rows);
|
||||||
|
$table->setHeaders(
|
||||||
|
array(
|
||||||
|
'Key',
|
||||||
|
'Value',
|
||||||
|
));
|
||||||
|
$table->setColumnClasses(
|
||||||
|
array(
|
||||||
|
'header',
|
||||||
|
'wide wrap',
|
||||||
|
));
|
||||||
|
|
||||||
|
return $table->render();
|
||||||
|
}
|
||||||
|
}
|
4
src/infrastructure/env/PhabricatorEnv.php
vendored
4
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -31,4 +31,8 @@ final class PhabricatorEnv {
|
||||||
return rtrim(self::getEnvConfig('phabricator.base-uri'), '/').$path;
|
return rtrim(self::getEnvConfig('phabricator.base-uri'), '/').$path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getAllConfigKeys() {
|
||||||
|
return self::$env;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue