mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Use an HTTPEngineExtension to implement "https.blindly-trust-domains" in Arcanist
Summary: Ref T10227. This converts weird hard-codey magic to the new HTTPEngineExtension. Test Plan: See D16090. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10227 Differential Revision: https://secure.phabricator.com/D16091
This commit is contained in:
parent
c75b671b22
commit
c13e5a6295
3 changed files with 32 additions and 1 deletions
|
@ -284,7 +284,9 @@ try {
|
||||||
$blind_key = 'https.blindly-trust-domains';
|
$blind_key = 'https.blindly-trust-domains';
|
||||||
$blind_trust = $configuration_manager->getConfigFromAnySource($blind_key);
|
$blind_trust = $configuration_manager->getConfigFromAnySource($blind_key);
|
||||||
if ($blind_trust) {
|
if ($blind_trust) {
|
||||||
HTTPSFuture::setBlindlyTrustDomains($blind_trust);
|
$trust_extension = PhutilHTTPEngineExtension::requireExtension(
|
||||||
|
ArcanistBlindlyTrustHTTPEngineExtension::EXTENSIONKEY);
|
||||||
|
$trust_extension->setDomains($blind_trust);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($need_conduit) {
|
if ($need_conduit) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase.php',
|
'ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase.php',
|
||||||
'ArcanistBlacklistedFunctionXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBlacklistedFunctionXHPASTLinterRule.php',
|
'ArcanistBlacklistedFunctionXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBlacklistedFunctionXHPASTLinterRule.php',
|
||||||
'ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase.php',
|
'ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase.php',
|
||||||
|
'ArcanistBlindlyTrustHTTPEngineExtension' => 'configuration/ArcanistBlindlyTrustHTTPEngineExtension.php',
|
||||||
'ArcanistBookmarkWorkflow' => 'workflow/ArcanistBookmarkWorkflow.php',
|
'ArcanistBookmarkWorkflow' => 'workflow/ArcanistBookmarkWorkflow.php',
|
||||||
'ArcanistBraceFormattingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php',
|
'ArcanistBraceFormattingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php',
|
||||||
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBraceFormattingXHPASTLinterRuleTestCase.php',
|
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBraceFormattingXHPASTLinterRuleTestCase.php',
|
||||||
|
@ -450,6 +451,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
'ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||||
'ArcanistBlacklistedFunctionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistBlacklistedFunctionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
'ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||||
|
'ArcanistBlindlyTrustHTTPEngineExtension' => 'PhutilHTTPEngineExtension',
|
||||||
'ArcanistBookmarkWorkflow' => 'ArcanistFeatureWorkflow',
|
'ArcanistBookmarkWorkflow' => 'ArcanistFeatureWorkflow',
|
||||||
'ArcanistBraceFormattingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistBraceFormattingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ArcanistBlindlyTrustHTTPEngineExtension
|
||||||
|
extends PhutilHTTPEngineExtension {
|
||||||
|
|
||||||
|
const EXTENSIONKEY = 'arc.https.blind';
|
||||||
|
|
||||||
|
private $domains = array();
|
||||||
|
|
||||||
|
public function setDomains(array $domains) {
|
||||||
|
foreach ($domains as $domain) {
|
||||||
|
$this->domains[phutil_utf8_strtolower($domain)] = true;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExtensionName() {
|
||||||
|
return pht('Arcanist HTTPS Trusted Domains');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldTrustAnySSLAuthorityForURI(PhutilURI $uri) {
|
||||||
|
$domain = $uri->getDomain();
|
||||||
|
$domain = phutil_utf8_strtolower($domain);
|
||||||
|
return isset($this->domains[$domain]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue