Page MenuHomePhabricator

D18306.id44014.diff
No OneTemporary

D18306.id44014.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -747,7 +747,6 @@
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
'DiffusionLowLevelMercurialPathsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php',
- 'DiffusionLowLevelMercurialPathsQueryTests' => 'applications/diffusion/query/lowlevel/__tests__/DiffusionLowLevelMercurialPathsQueryTests.php',
'DiffusionLowLevelParentsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelParentsQuery.php',
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
'DiffusionLowLevelResolveRefsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php',
@@ -3857,7 +3856,6 @@
'PhabricatorRepositoryURITransaction' => 'applications/repository/storage/PhabricatorRepositoryURITransaction.php',
'PhabricatorRepositoryURITransactionQuery' => 'applications/repository/query/PhabricatorRepositoryURITransactionQuery.php',
'PhabricatorRepositoryVCSPassword' => 'applications/repository/storage/PhabricatorRepositoryVCSPassword.php',
- 'PhabricatorRepositoryVersion' => 'applications/repository/constants/PhabricatorRepositoryVersion.php',
'PhabricatorRepositoryWorkingCopyVersion' => 'applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php',
'PhabricatorRequestExceptionHandler' => 'aphront/handler/PhabricatorRequestExceptionHandler.php',
'PhabricatorResourceSite' => 'aphront/site/PhabricatorResourceSite.php',
@@ -5741,7 +5739,6 @@
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelMercurialPathsQuery' => 'DiffusionLowLevelQuery',
- 'DiffusionLowLevelMercurialPathsQueryTests' => 'PhabricatorTestCase',
'DiffusionLowLevelParentsQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelQuery' => 'Phobject',
'DiffusionLowLevelResolveRefsQuery' => 'DiffusionLowLevelQuery',
@@ -9387,7 +9384,6 @@
'PhabricatorRepositoryURITransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorRepositoryURITransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorRepositoryVCSPassword' => 'PhabricatorRepositoryDAO',
- 'PhabricatorRepositoryVersion' => 'Phobject',
'PhabricatorRepositoryWorkingCopyVersion' => 'PhabricatorRepositoryDAO',
'PhabricatorRequestExceptionHandler' => 'AphrontRequestExceptionHandler',
'PhabricatorResourceSite' => 'PhabricatorSite',
diff --git a/src/applications/config/check/PhabricatorBinariesSetupCheck.php b/src/applications/config/check/PhabricatorBinariesSetupCheck.php
--- a/src/applications/config/check/PhabricatorBinariesSetupCheck.php
+++ b/src/applications/config/check/PhabricatorBinariesSetupCheck.php
@@ -99,12 +99,12 @@
continue;
}
- $version = null;
+ $version = PhutilBinaryAnalyzer::getForBinary($binary)
+ ->getBinaryVersion();
+
switch ($vcs['versionControlSystem']) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$bad_versions = array();
- list($err, $stdout, $stderr) = exec_manual('git --version');
- $version = trim(substr($stdout, strlen('git version ')));
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$bad_versions = array(
@@ -117,8 +117,6 @@
'for files added in rN (Subversion issue #2873), fixed in 1.7.2.',
'svn diff -c N'),
);
- list($err, $stdout, $stderr) = exec_manual('svn --version --quiet');
- $version = trim($stdout);
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$bad_versions = array(
@@ -134,7 +132,6 @@
'in 2.2.1. Pushing fails with this version as well; see %s.',
'T3046#54922'),
);
- $version = PhabricatorRepositoryVersion::getMercurialVersion();
break;
}
diff --git a/src/applications/config/controller/PhabricatorConfigVersionController.php b/src/applications/config/controller/PhabricatorConfigVersionController.php
--- a/src/applications/config/controller/PhabricatorConfigVersionController.php
+++ b/src/applications/config/controller/PhabricatorConfigVersionController.php
@@ -64,6 +64,29 @@
$version_from_file);
}
+ $binaries = PhutilBinaryAnalyzer::getAllBinaries();
+ foreach ($binaries as $binary) {
+ if (!$binary->isBinaryAvailable()) {
+ $binary_info = pht('Not Available');
+ } else {
+ $version = $binary->getBinaryVersion();
+ $path = $binary->getBinaryPath();
+ if ($path === null && $version === null) {
+ $binary_info = pht('-');
+ } else if ($path === null) {
+ $binary_info = $version;
+ } else if ($version === null) {
+ $binary_info = pht('- at %s', $path);
+ } else {
+ $binary_info = pht('%s at %s', $version, $path);
+ }
+ }
+
+ $version_property_list->addProperty(
+ $binary->getBinaryName(),
+ $binary_info);
+ }
+
return $version_property_list;
}
diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php
--- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php
@@ -24,11 +24,12 @@
$path = $this->path;
$commit = $this->commit;
- $hg_paths_command = 'locate --print0 --rev %s -I %s';
- $hg_version = PhabricatorRepositoryVersion::getMercurialVersion();
- if (PhabricatorRepositoryVersion::isMercurialFilesCommandAvailable(
- $hg_version)) {
+ $has_files = PhutilBinaryAnalyzer::getForBinary('hg')
+ ->isMercurialFilesCommandAvailable();
+ if ($has_files) {
$hg_paths_command = 'files --print0 --rev %s -I %s';
+ } else {
+ $hg_paths_command = 'locate --print0 --rev %s -I %s';
}
$match_against = trim($path, '/');
diff --git a/src/applications/diffusion/query/lowlevel/__tests__/DiffusionLowLevelMercurialPathsQueryTests.php b/src/applications/diffusion/query/lowlevel/__tests__/DiffusionLowLevelMercurialPathsQueryTests.php
deleted file mode 100644
--- a/src/applications/diffusion/query/lowlevel/__tests__/DiffusionLowLevelMercurialPathsQueryTests.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-final class DiffusionLowLevelMercurialPathsQueryTests
- extends PhabricatorTestCase {
-
- public function testCommandByVersion() {
- $cases = array(
- array(
- 'name' => pht('Versions which should not use `files`'),
- 'versions' => array('2.6.2', '2.9', '3.1'),
- 'match' => false,
- ),
-
- array(
- 'name' => pht('Versions which should use `files`'),
- 'versions' => array('3.2', '3.3', '3.5.2'),
- 'match' => true,
- ),
- );
-
- foreach ($cases as $case) {
- foreach ($case['versions'] as $version) {
- $actual = PhabricatorRepositoryVersion
- ::isMercurialFilesCommandAvailable($version);
- $expect = $case['match'];
- $this->assertEqual($expect, $actual, $case['name']);
- }
- }
- }
-
-}
diff --git a/src/applications/repository/constants/PhabricatorRepositoryVersion.php b/src/applications/repository/constants/PhabricatorRepositoryVersion.php
deleted file mode 100644
--- a/src/applications/repository/constants/PhabricatorRepositoryVersion.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-final class PhabricatorRepositoryVersion extends Phobject {
-
- public static function getMercurialVersion() {
- list($err, $stdout, $stderr) = exec_manual('hg --version --quiet');
-
- // NOTE: At least on OSX, recent versions of Mercurial report this
- // string in this format:
- //
- // Mercurial Distributed SCM (version 3.1.1+20140916)
-
- $matches = null;
- $pattern = '/^Mercurial Distributed SCM \(version ([\d.]+)/m';
- if (preg_match($pattern, $stdout, $matches)) {
- return $matches[1];
- }
-
- return null;
- }
-
- /**
- * The `locate` command is deprecated as of Mercurial 3.2, to be
- * replaced with `files` command, which supports most of the same
- * arguments. This determines whether the new `files` command should
- * be used instead of the `locate` command.
- *
- * @param string $mercurial_version - The current version of mercurial
- * which can be retrieved by calling:
- * PhabricatorRepositoryVersion::getMercurialVersion()
- *
- * @return boolean True if the version of Mercurial is new enough to support
- * the `files` command, or false if otherwise.
- */
- public static function isMercurialFilesCommandAvailable($mercurial_version) {
- $min_version_for_files = '3.2';
- return version_compare($mercurial_version, $min_version_for_files, '>=');
- }
-
-}
diff --git a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
--- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
@@ -485,8 +485,8 @@
// On vulnerable versions of Mercurial, we refuse to clone remotes which
// contain characters which may be interpreted by the shell.
- $hg_version = PhabricatorRepositoryVersion::getMercurialVersion();
- $is_vulnerable = version_compare($hg_version, '3.2.4', '<');
+ $hg_binary = PhutilBinaryAnalyzer::getForBinary('hg');
+ $is_vulnerable = $hg_binary->isMercurialVulnerableToInjection();
if ($is_vulnerable) {
$cleartext = $remote->openEnvelope();
// The use of "%R" here is an attempt to limit collateral damage
@@ -501,7 +501,7 @@
'command injection security vulnerability. The remote URI for '.
'this repository (%s) is potentially unsafe. Upgrade Mercurial '.
'to at least 3.2.4 to clone it.',
- $hg_version,
+ $hg_binary->getBinaryVersion(),
$repository->getMonogram()));
}
}

File Metadata

Mime Type
text/plain
Expires
Mar 17 2025, 10:01 AM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7614168
Default Alt Text
D18306.id44014.diff (10 KB)

Event Timeline