mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Never generate file download forms which point to the CDN domain, tighten "form-action" CSP
Summary: Depends on D19155. Ref T13094. Ref T4340. We can't currently implement a strict `form-action 'self'` content security policy because some file downloads rely on a `<form />` which sometimes POSTs to the CDN domain. Broadly, stop generating these forms. We just redirect instead, and show an interstitial confirm dialog if no CDN domain is configured. This makes the UX for installs with no CDN domain a little worse and the UX for everyone else better. Then, implement the stricter Content-Security-Policy. This also removes extra confirm dialogs for downloading Harbormaster build logs and data exports. Test Plan: - Went through the plain data export, data export with bulk jobs, ssh key generation, calendar ICS download, Diffusion data, Paste data, Harbormaster log data, and normal file data download workflows with a CDN domain. - Went through all those workflows again without a CDN domain. - Grepped for affected symbols (`getCDNURI()`, `getDownloadURI()`). - Added an evil form to a page, tried to submit it, was rejected. - Went through the ReCaptcha and Stripe flows again to see if they're submitting any forms. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13094, T4340 Differential Revision: https://secure.phabricator.com/D19156
This commit is contained in:
parent
afc98f5d5d
commit
ab579f2511
16 changed files with 118 additions and 82 deletions
|
@ -10,7 +10,7 @@ return array(
|
||||||
'conpherence.pkg.css' => 'e68cf1fa',
|
'conpherence.pkg.css' => 'e68cf1fa',
|
||||||
'conpherence.pkg.js' => '15191c65',
|
'conpherence.pkg.js' => '15191c65',
|
||||||
'core.pkg.css' => '2fa91e14',
|
'core.pkg.css' => '2fa91e14',
|
||||||
'core.pkg.js' => '7aa5bd92',
|
'core.pkg.js' => 'e7ce7bba',
|
||||||
'darkconsole.pkg.js' => '1f9a31bc',
|
'darkconsole.pkg.js' => '1f9a31bc',
|
||||||
'differential.pkg.css' => '113e692c',
|
'differential.pkg.css' => '113e692c',
|
||||||
'differential.pkg.js' => 'f6d809c0',
|
'differential.pkg.js' => 'f6d809c0',
|
||||||
|
@ -255,7 +255,7 @@ return array(
|
||||||
'rsrc/externals/javelin/lib/URI.js' => 'c989ade3',
|
'rsrc/externals/javelin/lib/URI.js' => 'c989ade3',
|
||||||
'rsrc/externals/javelin/lib/Vector.js' => '2caa8fb8',
|
'rsrc/externals/javelin/lib/Vector.js' => '2caa8fb8',
|
||||||
'rsrc/externals/javelin/lib/WebSocket.js' => '3ffe32d6',
|
'rsrc/externals/javelin/lib/WebSocket.js' => '3ffe32d6',
|
||||||
'rsrc/externals/javelin/lib/Workflow.js' => '1e911d0f',
|
'rsrc/externals/javelin/lib/Workflow.js' => '0eb1db0c',
|
||||||
'rsrc/externals/javelin/lib/__tests__/Cookie.js' => '5ed109e8',
|
'rsrc/externals/javelin/lib/__tests__/Cookie.js' => '5ed109e8',
|
||||||
'rsrc/externals/javelin/lib/__tests__/DOM.js' => 'c984504b',
|
'rsrc/externals/javelin/lib/__tests__/DOM.js' => 'c984504b',
|
||||||
'rsrc/externals/javelin/lib/__tests__/JSON.js' => '837a7d68',
|
'rsrc/externals/javelin/lib/__tests__/JSON.js' => '837a7d68',
|
||||||
|
@ -757,7 +757,7 @@ return array(
|
||||||
'javelin-workboard-card' => 'c587b80f',
|
'javelin-workboard-card' => 'c587b80f',
|
||||||
'javelin-workboard-column' => '758b4758',
|
'javelin-workboard-column' => '758b4758',
|
||||||
'javelin-workboard-controller' => '26167537',
|
'javelin-workboard-controller' => '26167537',
|
||||||
'javelin-workflow' => '1e911d0f',
|
'javelin-workflow' => '0eb1db0c',
|
||||||
'maniphest-report-css' => '9b9580b7',
|
'maniphest-report-css' => '9b9580b7',
|
||||||
'maniphest-task-edit-css' => 'fda62a9b',
|
'maniphest-task-edit-css' => 'fda62a9b',
|
||||||
'maniphest-task-summary-css' => '11cc5344',
|
'maniphest-task-summary-css' => '11cc5344',
|
||||||
|
@ -977,6 +977,17 @@ return array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
'javelin-router',
|
'javelin-router',
|
||||||
),
|
),
|
||||||
|
'0eb1db0c' => array(
|
||||||
|
'javelin-stratcom',
|
||||||
|
'javelin-request',
|
||||||
|
'javelin-dom',
|
||||||
|
'javelin-vector',
|
||||||
|
'javelin-install',
|
||||||
|
'javelin-util',
|
||||||
|
'javelin-mask',
|
||||||
|
'javelin-uri',
|
||||||
|
'javelin-routable',
|
||||||
|
),
|
||||||
'0f764c35' => array(
|
'0f764c35' => array(
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
'javelin-util',
|
'javelin-util',
|
||||||
|
@ -1035,17 +1046,6 @@ return array(
|
||||||
'javelin-request',
|
'javelin-request',
|
||||||
'javelin-uri',
|
'javelin-uri',
|
||||||
),
|
),
|
||||||
'1e911d0f' => array(
|
|
||||||
'javelin-stratcom',
|
|
||||||
'javelin-request',
|
|
||||||
'javelin-dom',
|
|
||||||
'javelin-vector',
|
|
||||||
'javelin-install',
|
|
||||||
'javelin-util',
|
|
||||||
'javelin-mask',
|
|
||||||
'javelin-uri',
|
|
||||||
'javelin-routable',
|
|
||||||
),
|
|
||||||
'1f6794f6' => array(
|
'1f6794f6' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
|
|
@ -8,6 +8,7 @@ class AphrontRedirectResponse extends AphrontResponse {
|
||||||
private $uri;
|
private $uri;
|
||||||
private $stackWhenCreated;
|
private $stackWhenCreated;
|
||||||
private $isExternal;
|
private $isExternal;
|
||||||
|
private $closeDialogBeforeRedirect;
|
||||||
|
|
||||||
public function setIsExternal($external) {
|
public function setIsExternal($external) {
|
||||||
$this->isExternal = $external;
|
$this->isExternal = $external;
|
||||||
|
@ -37,6 +38,15 @@ class AphrontRedirectResponse extends AphrontResponse {
|
||||||
return PhabricatorEnv::getEnvConfig('debug.stop-on-redirect');
|
return PhabricatorEnv::getEnvConfig('debug.stop-on-redirect');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCloseDialogBeforeRedirect($close) {
|
||||||
|
$this->closeDialogBeforeRedirect = $close;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCloseDialogBeforeRedirect() {
|
||||||
|
return $this->closeDialogBeforeRedirect;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHeaders() {
|
public function getHeaders() {
|
||||||
$headers = array();
|
$headers = array();
|
||||||
if (!$this->shouldStopForDebugging()) {
|
if (!$this->shouldStopForDebugging()) {
|
||||||
|
|
|
@ -147,6 +147,13 @@ abstract class AphrontResponse extends Phobject {
|
||||||
// Block relics of the old world: Flash, Java applets, and so on.
|
// Block relics of the old world: Flash, Java applets, and so on.
|
||||||
$csp[] = "object-src 'none'";
|
$csp[] = "object-src 'none'";
|
||||||
|
|
||||||
|
// Don't allow forms to submit offsite.
|
||||||
|
|
||||||
|
// This can result in some trickiness with file downloads if applications
|
||||||
|
// try to start downloads by submitting a dialog. Redirect to the file's
|
||||||
|
// download URI instead of submitting a form to it.
|
||||||
|
$csp[] = "form-action 'self'";
|
||||||
|
|
||||||
$csp = implode('; ', $csp);
|
$csp = implode('; ', $csp);
|
||||||
|
|
||||||
return $csp;
|
return $csp;
|
||||||
|
|
|
@ -24,10 +24,12 @@ final class PhabricatorAuthSSHKeyGenerateController
|
||||||
$keys = PhabricatorSSHKeyGenerator::generateKeypair();
|
$keys = PhabricatorSSHKeyGenerator::generateKeypair();
|
||||||
list($public_key, $private_key) = $keys;
|
list($public_key, $private_key) = $keys;
|
||||||
|
|
||||||
|
$key_name = $default_name.'.key';
|
||||||
|
|
||||||
$file = PhabricatorFile::newFromFileData(
|
$file = PhabricatorFile::newFromFileData(
|
||||||
$private_key,
|
$private_key,
|
||||||
array(
|
array(
|
||||||
'name' => $default_name.'.key',
|
'name' => $key_name,
|
||||||
'ttl.relative' => phutil_units('10 minutes in seconds'),
|
'ttl.relative' => phutil_units('10 minutes in seconds'),
|
||||||
'viewPolicy' => $viewer->getPHID(),
|
'viewPolicy' => $viewer->getPHID(),
|
||||||
));
|
));
|
||||||
|
@ -62,25 +64,33 @@ final class PhabricatorAuthSSHKeyGenerateController
|
||||||
->setContentSourceFromRequest($request)
|
->setContentSourceFromRequest($request)
|
||||||
->applyTransactions($key, $xactions);
|
->applyTransactions($key, $xactions);
|
||||||
|
|
||||||
// NOTE: We're disabling workflow on submit so the download works. We're
|
$download_link = phutil_tag(
|
||||||
// disabling workflow on cancel so the page reloads, showing the new
|
'a',
|
||||||
// key.
|
array(
|
||||||
|
'href' => $file->getDownloadURI(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
id(new PHUIIconView())->setIcon('fa-download'),
|
||||||
|
' ',
|
||||||
|
pht('Download Private Key (%s)', $key_name),
|
||||||
|
));
|
||||||
|
$download_link = phutil_tag('strong', array(), $download_link);
|
||||||
|
|
||||||
|
// NOTE: We're disabling workflow on cancel so the page reloads, showing
|
||||||
|
// the new key.
|
||||||
|
|
||||||
return $this->newDialog()
|
return $this->newDialog()
|
||||||
->setTitle(pht('Download Private Key'))
|
->setTitle(pht('Download Private Key'))
|
||||||
->setDisableWorkflowOnCancel(true)
|
|
||||||
->setDisableWorkflowOnSubmit(true)
|
|
||||||
->setSubmitURI($file->getDownloadURI())
|
|
||||||
->appendParagraph(
|
->appendParagraph(
|
||||||
pht(
|
pht(
|
||||||
'A keypair has been generated, and the public key has been '.
|
'A keypair has been generated, and the public key has been '.
|
||||||
'added as a recognized key. Use the button below to download '.
|
'added as a recognized key.'))
|
||||||
'the private key.'))
|
->appendParagraph($download_link)
|
||||||
->appendParagraph(
|
->appendParagraph(
|
||||||
pht(
|
pht(
|
||||||
'After you download the private key, it will be destroyed. '.
|
'After you download the private key, it will be destroyed. '.
|
||||||
'You will not be able to retrieve it if you lose your copy.'))
|
'You will not be able to retrieve it if you lose your copy.'))
|
||||||
->addSubmitButton(pht('Download Private Key'))
|
->setDisableWorkflowOnCancel(true)
|
||||||
->addCancelButton($cancel_uri, pht('Done'));
|
->addCancelButton($cancel_uri, pht('Done'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,6 +298,7 @@ abstract class PhabricatorController extends AphrontController {
|
||||||
->setContent(
|
->setContent(
|
||||||
array(
|
array(
|
||||||
'redirect' => $response->getURI(),
|
'redirect' => $response->getURI(),
|
||||||
|
'close' => $response->getCloseDialogBeforeRedirect(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1046,7 +1046,7 @@ final class DiffusionServeController extends DiffusionController {
|
||||||
// <https://github.com/github/git-lfs/issues/1088>
|
// <https://github.com/github/git-lfs/issues/1088>
|
||||||
$no_authorization = 'Basic '.base64_encode('none');
|
$no_authorization = 'Basic '.base64_encode('none');
|
||||||
|
|
||||||
$get_uri = $file->getCDNURI();
|
$get_uri = $file->getCDNURI('data');
|
||||||
$actions['download'] = array(
|
$actions['download'] = array(
|
||||||
'href' => $get_uri,
|
'href' => $get_uri,
|
||||||
'header' => array(
|
'header' => array(
|
||||||
|
|
|
@ -101,7 +101,7 @@ final class PhabricatorFilesApplication extends PhabricatorApplication {
|
||||||
|
|
||||||
private function getResourceSubroutes() {
|
private function getResourceSubroutes() {
|
||||||
return array(
|
return array(
|
||||||
'data/'.
|
'(?P<kind>data|download)/'.
|
||||||
'(?:@(?P<instance>[^/]+)/)?'.
|
'(?:@(?P<instance>[^/]+)/)?'.
|
||||||
'(?P<key>[^/]+)/'.
|
'(?P<key>[^/]+)/'.
|
||||||
'(?P<phid>[^/]+)/'.
|
'(?P<phid>[^/]+)/'.
|
||||||
|
@ -132,7 +132,7 @@ final class PhabricatorFilesApplication extends PhabricatorApplication {
|
||||||
|
|
||||||
public function getQuicksandURIPatternBlacklist() {
|
public function getQuicksandURIPatternBlacklist() {
|
||||||
return array(
|
return array(
|
||||||
'/file/data/.*',
|
'/file/(data|download)/.*',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
||||||
$req_domain = $request->getHost();
|
$req_domain = $request->getHost();
|
||||||
$main_domain = id(new PhutilURI($base_uri))->getDomain();
|
$main_domain = id(new PhutilURI($base_uri))->getDomain();
|
||||||
|
|
||||||
|
$request_kind = $request->getURIData('kind');
|
||||||
|
$is_download = ($request_kind === 'download');
|
||||||
|
|
||||||
if (!strlen($alt) || $main_domain == $alt_domain) {
|
if (!strlen($alt) || $main_domain == $alt_domain) {
|
||||||
// No alternate domain.
|
// No alternate domain.
|
||||||
$should_redirect = false;
|
$should_redirect = false;
|
||||||
|
@ -50,7 +53,7 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
||||||
if ($should_redirect) {
|
if ($should_redirect) {
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setIsExternal(true)
|
->setIsExternal(true)
|
||||||
->setURI($file->getCDNURI());
|
->setURI($file->getCDNURI($request_kind));
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = new AphrontFileResponse();
|
$response = new AphrontFileResponse();
|
||||||
|
@ -71,34 +74,30 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_viewable = $file->isViewableInBrowser();
|
$is_viewable = $file->isViewableInBrowser();
|
||||||
$force_download = $request->getExists('download');
|
|
||||||
|
|
||||||
$request_type = $request->getHTTPHeader('X-Phabricator-Request-Type');
|
$request_type = $request->getHTTPHeader('X-Phabricator-Request-Type');
|
||||||
$is_lfs = ($request_type == 'git-lfs');
|
$is_lfs = ($request_type == 'git-lfs');
|
||||||
|
|
||||||
if ($is_viewable && !$force_download) {
|
if ($is_viewable && !$is_download) {
|
||||||
$response->setMimeType($file->getViewableMimeType());
|
$response->setMimeType($file->getViewableMimeType());
|
||||||
} else {
|
} else {
|
||||||
$is_public = !$viewer->isLoggedIn();
|
|
||||||
$is_post = $request->isHTTPPost();
|
$is_post = $request->isHTTPPost();
|
||||||
|
|
||||||
// NOTE: Require POST to download files from the primary domain if the
|
// NOTE: Require POST to download files from the primary domain. If the
|
||||||
// request includes credentials. The "Download File" links we generate
|
// request is not a POST request but arrives on the primary domain, we
|
||||||
// in the web UI are forms which use POST to satisfy this requirement.
|
// render a confirmation dialog. For discussion, see T13094.
|
||||||
|
|
||||||
// The intent is to make attacks based on tags like "<iframe />" and
|
$is_safe = ($is_alternate_domain || $is_lfs || $is_post);
|
||||||
// "<script />" (which can issue GET requests, but can not easily issue
|
|
||||||
// POST requests) more difficult to execute.
|
|
||||||
|
|
||||||
// The best defense against these attacks is to use an alternate file
|
|
||||||
// domain, which is why we strongly recommend doing so.
|
|
||||||
|
|
||||||
$is_safe = ($is_alternate_domain || $is_lfs || $is_post || $is_public);
|
|
||||||
if (!$is_safe) {
|
if (!$is_safe) {
|
||||||
// This is marked as "external" because it is fully qualified.
|
return $this->newDialog()
|
||||||
return id(new AphrontRedirectResponse())
|
->setSubmitURI($file->getDownloadURI())
|
||||||
->setIsExternal(true)
|
->setTitle(pht('Download File'))
|
||||||
->setURI(PhabricatorEnv::getProductionURI($file->getBestURI()));
|
->appendParagraph(
|
||||||
|
pht(
|
||||||
|
'Download file %s (%s)?',
|
||||||
|
phutil_tag('strong', array(), $file->getName()),
|
||||||
|
phutil_format_bytes($file->getByteSize())))
|
||||||
|
->addCancelButton($file->getURI())
|
||||||
|
->addSubmitButton(pht('Download File'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->setMimeType($file->getMimeType());
|
$response->setMimeType($file->getMimeType());
|
||||||
|
|
|
@ -137,11 +137,10 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setRenderAsForm($can_download)
|
|
||||||
->setDownload($can_download)
|
->setDownload($can_download)
|
||||||
->setName(pht('Download File'))
|
->setName(pht('Download File'))
|
||||||
->setIcon('fa-download')
|
->setIcon('fa-download')
|
||||||
->setHref($file->getViewURI())
|
->setHref($file->getDownloadURI())
|
||||||
->setDisabled(!$can_download)
|
->setDisabled(!$can_download)
|
||||||
->setWorkflow(!$can_download));
|
->setWorkflow(!$can_download));
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ final class PhabricatorEmbedFileRemarkupRule
|
||||||
|
|
||||||
$existing_xform = $file->getTransform($preview_key);
|
$existing_xform = $file->getTransform($preview_key);
|
||||||
if ($existing_xform) {
|
if ($existing_xform) {
|
||||||
$xform_uri = $existing_xform->getCDNURI();
|
$xform_uri = $existing_xform->getCDNURI('data');
|
||||||
} else {
|
} else {
|
||||||
$xform_uri = $file->getURIForTransform($xform);
|
$xform_uri = $file->getURIForTransform($xform);
|
||||||
}
|
}
|
||||||
|
|
|
@ -810,16 +810,24 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
||||||
pht('You must save a file before you can generate a view URI.'));
|
pht('You must save a file before you can generate a view URI.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getCDNURI();
|
return $this->getCDNURI('data');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCDNURI($request_kind) {
|
||||||
|
if (($request_kind !== 'data') &&
|
||||||
|
($request_kind !== 'download')) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Unknown file content request kind "%s".',
|
||||||
|
$request_kind));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCDNURI() {
|
|
||||||
$name = self::normalizeFileName($this->getName());
|
$name = self::normalizeFileName($this->getName());
|
||||||
$name = phutil_escape_uri($name);
|
$name = phutil_escape_uri($name);
|
||||||
|
|
||||||
$parts = array();
|
$parts = array();
|
||||||
$parts[] = 'file';
|
$parts[] = 'file';
|
||||||
$parts[] = 'data';
|
$parts[] = $request_kind;
|
||||||
|
|
||||||
// If this is an instanced install, add the instance identifier to the URI.
|
// If this is an instanced install, add the instance identifier to the URI.
|
||||||
// Instanced configurations behind a CDN may not be able to control the
|
// Instanced configurations behind a CDN may not be able to control the
|
||||||
|
@ -861,9 +869,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDownloadURI() {
|
public function getDownloadURI() {
|
||||||
$uri = id(new PhutilURI($this->getViewURI()))
|
return $this->getCDNURI('download');
|
||||||
->setQueryParam('download', true);
|
|
||||||
return (string)$uri;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURIForTransform(PhabricatorFileTransform $transform) {
|
public function getURIForTransform(PhabricatorFileTransform $transform) {
|
||||||
|
@ -1469,6 +1475,16 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
||||||
->setURI($uri);
|
->setURI($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function newDownloadResponse() {
|
||||||
|
// We're cheating a little bit here and relying on the fact that
|
||||||
|
// getDownloadURI() always returns a fully qualified URI with a complete
|
||||||
|
// domain.
|
||||||
|
return id(new AphrontRedirectResponse())
|
||||||
|
->setIsExternal(true)
|
||||||
|
->setCloseDialogBeforeRedirect(true)
|
||||||
|
->setURI($this->getDownloadURI());
|
||||||
|
}
|
||||||
|
|
||||||
public function attachTransforms(array $map) {
|
public function attachTransforms(array $map) {
|
||||||
$this->transforms = $map;
|
$this->transforms = $map;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -44,19 +44,7 @@ final class HarbormasterBuildLogDownloadController
|
||||||
->addCancelButton($cancel_uri);
|
->addCancelButton($cancel_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
$size = $file->getByteSize();
|
return $file->newDownloadResponse();
|
||||||
|
|
||||||
return $this->newDialog()
|
|
||||||
->setTitle(pht('Download Build Log'))
|
|
||||||
->appendParagraph(
|
|
||||||
pht(
|
|
||||||
'This log has a total size of %s. If you insist, you may '.
|
|
||||||
'download it.',
|
|
||||||
phutil_tag('strong', array(), phutil_format_bytes($size))))
|
|
||||||
->setDisableWorkflowOnSubmit(true)
|
|
||||||
->addSubmitButton(pht('Download Log'))
|
|
||||||
->setSubmitURI($file->getDownloadURI())
|
|
||||||
->addCancelButton($cancel_uri, pht('Done'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,14 @@ final class HarbormasterBuildLogView extends AphrontView {
|
||||||
|
|
||||||
$download_uri = "/harbormaster/log/download/{$id}/";
|
$download_uri = "/harbormaster/log/download/{$id}/";
|
||||||
|
|
||||||
|
$can_download = (bool)$log->getFilePHID();
|
||||||
|
|
||||||
$download_button = id(new PHUIButtonView())
|
$download_button = id(new PHUIButtonView())
|
||||||
->setTag('a')
|
->setTag('a')
|
||||||
->setHref($download_uri)
|
->setHref($download_uri)
|
||||||
->setIcon('fa-download')
|
->setIcon('fa-download')
|
||||||
->setDisabled(!$log->getFilePHID())
|
->setDisabled(!$can_download)
|
||||||
->setWorkflow(true)
|
->setWorkflow(!$can_download)
|
||||||
->setText(pht('Download Log'));
|
->setText(pht('Download Log'));
|
||||||
|
|
||||||
$header->addActionLink($download_button);
|
$header->addActionLink($download_button);
|
||||||
|
|
|
@ -512,15 +512,7 @@ final class PhabricatorApplicationSearchController
|
||||||
->setURI($job->getMonitorURI());
|
->setURI($job->getMonitorURI());
|
||||||
} else {
|
} else {
|
||||||
$file = $export_engine->exportFile();
|
$file = $export_engine->exportFile();
|
||||||
|
return $file->newDownloadResponse();
|
||||||
return $this->newDialog()
|
|
||||||
->setTitle(pht('Download Results'))
|
|
||||||
->appendParagraph(
|
|
||||||
pht('Click the download button to download the exported data.'))
|
|
||||||
->addCancelButton($cancel_uri, pht('Done'))
|
|
||||||
->setSubmitURI($file->getDownloadURI())
|
|
||||||
->setDisableWorkflowOnSubmit(true)
|
|
||||||
->addSubmitButton(pht('Download Data'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,12 +527,18 @@ final class PhabricatorApplicationSearchController
|
||||||
->setValue($format_key)
|
->setValue($format_key)
|
||||||
->setOptions($format_options));
|
->setOptions($format_options));
|
||||||
|
|
||||||
|
if ($is_large_export) {
|
||||||
|
$submit_button = pht('Continue');
|
||||||
|
} else {
|
||||||
|
$submit_button = pht('Download Data');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->newDialog()
|
return $this->newDialog()
|
||||||
->setTitle(pht('Export Results'))
|
->setTitle(pht('Export Results'))
|
||||||
->setErrors($errors)
|
->setErrors($errors)
|
||||||
->appendForm($export_form)
|
->appendForm($export_form)
|
||||||
->addCancelButton($cancel_uri)
|
->addCancelButton($cancel_uri)
|
||||||
->addSubmitButton(pht('Continue'));
|
->addSubmitButton($submit_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processEditRequest() {
|
private function processEditRequest() {
|
||||||
|
|
|
@ -36,7 +36,6 @@ final class PhabricatorExportEngineBulkJobType
|
||||||
->setName(pht('Temporary File Expired'));
|
->setName(pht('Temporary File Expired'));
|
||||||
} else {
|
} else {
|
||||||
$actions[] = id(new PhabricatorActionView())
|
$actions[] = id(new PhabricatorActionView())
|
||||||
->setRenderAsForm(true)
|
|
||||||
->setHref($file->getDownloadURI())
|
->setHref($file->getDownloadURI())
|
||||||
->setIcon('fa-download')
|
->setIcon('fa-download')
|
||||||
->setName(pht('Download Data Export'));
|
->setName(pht('Download Data Export'));
|
||||||
|
|
|
@ -276,6 +276,13 @@ JX.install('Workflow', {
|
||||||
// It is permissible to send back a falsey redirect to force a page
|
// It is permissible to send back a falsey redirect to force a page
|
||||||
// reload, so we need to take this branch if the key is present.
|
// reload, so we need to take this branch if the key is present.
|
||||||
if (r && (typeof r.redirect != 'undefined')) {
|
if (r && (typeof r.redirect != 'undefined')) {
|
||||||
|
// Before we redirect to file downloads, we close the dialog. These
|
||||||
|
// redirects aren't real navigation events so we end up stuck in the
|
||||||
|
// dialog otherwise.
|
||||||
|
if (r.close) {
|
||||||
|
this._pop();
|
||||||
|
}
|
||||||
|
|
||||||
JX.$U(r.redirect).go();
|
JX.$U(r.redirect).go();
|
||||||
} else if (r && r.dialog) {
|
} else if (r && r.dialog) {
|
||||||
this._push();
|
this._push();
|
||||||
|
|
Loading…
Reference in a new issue