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