1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-08 07:52:39 +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:
epriestley 2016-06-09 10:48:32 -07:00
parent c75b671b22
commit c13e5a6295
3 changed files with 32 additions and 1 deletions

View file

@ -284,7 +284,9 @@ try {
$blind_key = 'https.blindly-trust-domains';
$blind_trust = $configuration_manager->getConfigFromAnySource($blind_key);
if ($blind_trust) {
HTTPSFuture::setBlindlyTrustDomains($blind_trust);
$trust_extension = PhutilHTTPEngineExtension::requireExtension(
ArcanistBlindlyTrustHTTPEngineExtension::EXTENSIONKEY);
$trust_extension->setDomains($blind_trust);
}
if ($need_conduit) {

View file

@ -36,6 +36,7 @@ phutil_register_library_map(array(
'ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase.php',
'ArcanistBlacklistedFunctionXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBlacklistedFunctionXHPASTLinterRule.php',
'ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase.php',
'ArcanistBlindlyTrustHTTPEngineExtension' => 'configuration/ArcanistBlindlyTrustHTTPEngineExtension.php',
'ArcanistBookmarkWorkflow' => 'workflow/ArcanistBookmarkWorkflow.php',
'ArcanistBraceFormattingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php',
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBraceFormattingXHPASTLinterRuleTestCase.php',
@ -450,6 +451,7 @@ phutil_register_library_map(array(
'ArcanistBinaryNumericScalarCasingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistBlacklistedFunctionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistBlacklistedFunctionXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistBlindlyTrustHTTPEngineExtension' => 'PhutilHTTPEngineExtension',
'ArcanistBookmarkWorkflow' => 'ArcanistFeatureWorkflow',
'ArcanistBraceFormattingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',

View file

@ -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]);
}
}