mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Mask remaining config values, and implement set
type
Summary: The remaining hash/key values are already-migrated, I am just bad at grep. Also implement a "set" type. Test Plan: Looked at set, edited set. Reviewers: codeblock, btrahan Reviewed By: codeblock CC: aran Maniphest Tasks: T2255 Differential Revision: https://secure.phabricator.com/D4476
This commit is contained in:
parent
9f549ba75e
commit
99847da3aa
6 changed files with 41 additions and 14 deletions
|
@ -258,6 +258,9 @@ final class PhabricatorConfigEditController
|
|||
case 'list<string>':
|
||||
$set_value = $request->getStrList('value');
|
||||
break;
|
||||
case 'set':
|
||||
$set_value = array_fill_keys($request->getStrList('value'), true);
|
||||
break;
|
||||
case 'bool':
|
||||
switch ($value) {
|
||||
case 'true':
|
||||
|
@ -329,6 +332,8 @@ final class PhabricatorConfigEditController
|
|||
return $value ? 'true' : 'false';
|
||||
case 'list<string>':
|
||||
return implode("\n", nonempty($value, array()));
|
||||
case 'set':
|
||||
return implode("\n", nonempty(array_keys($value), array()));
|
||||
default:
|
||||
return PhabricatorConfigJSON::prettyPrintJSON($value);
|
||||
}
|
||||
|
@ -370,6 +375,7 @@ final class PhabricatorConfigEditController
|
|||
->setOptions($names);
|
||||
break;
|
||||
case 'list<string>':
|
||||
case 'set':
|
||||
$control = id(new AphrontFormTextAreaControl())
|
||||
->setCaption(pht('Separate values with newlines or commas.'));
|
||||
break;
|
||||
|
|
|
@ -11,15 +11,17 @@ final class PhabricatorConfigJSON {
|
|||
// Check not only that it's an array, but that it's an "unnatural" array
|
||||
// meaning that the keys aren't 0 -> size_of_array.
|
||||
if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) {
|
||||
return id(new PhutilJSON())->encodeFormatted($value);
|
||||
$result = id(new PhutilJSON())->encodeFormatted($value);
|
||||
} else {
|
||||
$result = json_encode($value);
|
||||
// For readability, unescape forward slashes. These are normally escaped
|
||||
// to prevent the string "</script>" from appearing in a JSON literal,
|
||||
// but it's irrelevant here and makes reading paths more difficult than
|
||||
// necessary.
|
||||
$result = str_replace('\\/', '/', $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// For readability, unescape forward slashes. These are normally escaped
|
||||
// to prevent the string "</script>" from appearing in a JSON literal,
|
||||
// but it's irrelevant here and makes reading paths more difficult than
|
||||
// necessary.
|
||||
$result = str_replace('\\/', '/', $result);
|
||||
return $result;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,24 @@ abstract class PhabricatorApplicationConfigOptions extends Phobject {
|
|||
$option->getBaseClass()));
|
||||
}
|
||||
break;
|
||||
case 'set':
|
||||
$valid = true;
|
||||
if (!is_array($value)) {
|
||||
throw new PhabricatorConfigValidationException(
|
||||
pht(
|
||||
"Option '%s' must be a set, but value is not an array.",
|
||||
$option->getKey()));
|
||||
}
|
||||
foreach ($value as $v) {
|
||||
if ($v !== true) {
|
||||
throw new PhabricatorConfigValidationException(
|
||||
pht(
|
||||
"Option '%s' must be a set, but array contains values other ".
|
||||
"than 'true'.",
|
||||
$option->getKey()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'list<string>':
|
||||
$valid = true;
|
||||
if (!is_array($value)) {
|
||||
|
|
|
@ -106,13 +106,13 @@ final class PhabricatorCoreConfigOptions
|
|||
"then playing with a user tokenizer (like the user selectors in ".
|
||||
"Maniphest or Differential) and seeing which setting loads ".
|
||||
"faster and feels better.")),
|
||||
$this->newOption('config.lock', 'wild', array())
|
||||
$this->newOption('config.lock', 'set', array())
|
||||
->setLocked(true)
|
||||
->setDescription(pht('Additional configuration options to lock.')),
|
||||
$this->newOption('config.hide', 'wild', array())
|
||||
$this->newOption('config.hide', 'set', array())
|
||||
->setLocked(true)
|
||||
->setDescription(pht('Additional configuration options to hide.')),
|
||||
$this->newOption('config.mask', 'wild', array())
|
||||
$this->newOption('config.mask', 'set', array())
|
||||
->setLocked(true)
|
||||
->setDescription(pht('Additional configuration options to mask.')),
|
||||
);
|
||||
|
|
|
@ -40,6 +40,7 @@ final class PhabricatorSecurityConfigOptions
|
|||
'security.hmac-key',
|
||||
'string',
|
||||
'[D\t~Y7eNmnQGJ;rnH6aF;m2!vJ8@v8C=Cs:aQS\.Qw')
|
||||
->setMasked(true)
|
||||
->setSummary(
|
||||
pht("Key for HMAC digests."))
|
||||
->setDescription(
|
||||
|
@ -82,6 +83,7 @@ final class PhabricatorSecurityConfigOptions
|
|||
'phabricator.csrf-key',
|
||||
'string',
|
||||
'0b7ec0592e0a2829d8b71df2fa269b2c6172eca3')
|
||||
->setMasked(true)
|
||||
->setSummary(
|
||||
pht("Hashed with other inputs to generate CSRF tokens."))
|
||||
->setDescription(
|
||||
|
@ -96,6 +98,7 @@ final class PhabricatorSecurityConfigOptions
|
|||
'phabricator.mail-key',
|
||||
'string',
|
||||
'5ce3e7e8787f6e40dfae861da315a5cdf1018f12')
|
||||
->setMasked(true)
|
||||
->setSummary(
|
||||
pht("Hashed with other inputs to generate mail tokens."))
|
||||
->setDescription(
|
||||
|
@ -105,9 +108,7 @@ final class PhabricatorSecurityConfigOptions
|
|||
"unique to your install. In particular, you will want to do ".
|
||||
"this if you accidentally send a bunch of mail somewhere you ".
|
||||
"shouldn't have, to invalidate all old reply-to addresses.")),
|
||||
// TODO: This should really be dict<string,bool> but that doesn't exist
|
||||
// yet.
|
||||
$this->newOption('uri.allowed-protocols', 'wild', null)
|
||||
$this->newOption('uri.allowed-protocols', 'set', null)
|
||||
->setSummary(
|
||||
pht("Determines which URI protocols are auto-linked."))
|
||||
->setDescription(
|
||||
|
|
|
@ -52,7 +52,7 @@ final class PhabricatorFilesConfigOptions
|
|||
'The keys in this map are vieweable MIME types; the values are '.
|
||||
'the MIME type sthey are delivered as when they are viewed in '.
|
||||
'the browser.')),
|
||||
$this->newOption('files.image-mime-types', 'wild', $image_default)
|
||||
$this->newOption('files.image-mime-types', 'set', $image_default)
|
||||
->setSummary(pht('Configure which MIME types are images.'))
|
||||
->setDescription(
|
||||
pht(
|
||||
|
|
Loading…
Reference in a new issue