Commit Graph

33905 Commits

Author SHA1 Message Date
Nathan Goldbaum
0de8be7e62 log: mention ui.logtemplate in the help text 2017-08-16 10:24:49 -05:00
Tristan Seligmann
0428b15b61 hg: avoid relying on errno numbers / descriptions
A few tests hardcode errno numbers and/or descriptions in the output, causing
test failures on platforms where these values are different.

Differential Revision: https://phab.mercurial-scm.org/D362
2017-08-12 14:29:22 +02:00
Tristan Seligmann
0fee28d767 hg: tolerate long vs. int in test-context.py
The file times here can be longs instead of ints on some platforms, which will
cause a test failure due to these printing with an L suffix; instead always
format with %d which will produce the same output in either case.

Differential Revision: https://phab.mercurial-scm.org/D361
2017-08-12 14:24:25 +02:00
Mike Hommey
634713aa96 setup: fix installing in a mingw environment
The addition, in 851d08ff7a58, of a hack for the MSVC compiler class was
overwriting the original class for the Mingw32CCompiler class, leading to an
error when the HackedMingw32CCompiler is instantiated.

Differential Revision: https://phab.mercurial-scm.org/D329
2017-08-11 10:16:00 +09:00
Kevin Bullock
5e1176676c osx: delay version computation on macOS builds
Before this patch, HGVER would be evaluated at the beginning of the make
execution, and would be unset because build/mercurial/ doesn't exist yet
at that point. Now we compute the version after the `make install` run
has completed.

This is backported to stable from 8626b44516c1, but that revision had an
error in the shell invocation syntax.
2017-08-10 21:25:02 -04:00
Mike Hommey
73f4a16a4f branchmap: revert a81106261d38 for Python 2.7 compatibility
Old versions of python 2.7 don't like that the second argument to
struct.unpack_from is a bytearray, so the change removing the util.buffer
around that argument in branchmap broke running on older versions of python
2.7.

Differential Revision: https://phab.mercurial-scm.org/D330
2017-08-10 20:47:19 -07:00
Augie Fackler
abe39330a6 Added signature for changeset 229937197835 2017-08-10 18:46:55 -04:00
Yuya Nishihara
509744ddfc ssh: unban the use of pipe character in user@host:port string
This vulnerability was fixed by the previous patch and there were more ways
to exploit than using '|shellcmd'. So it doesn't make sense to reject only
pipe character.

Test cases are updated to actually try to exploit the bug. As the SSH bridge
of git/svn subrepos are not managed by our code, the tests for non-hg subrepos
are just removed.

This may be folded into the original patches.
2017-08-07 22:22:28 +09:00
Jun Wu
a0e5a4defb ssh: quote parameters using shellquote (SEC)
This patch uses shellquote to quote ssh parameters more strictly to avoid
shell injection.
2017-08-04 23:54:12 -07:00
Sean Farley
39898f2a8a subrepo: add tests for git rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 14:55:11 -07:00
Sean Farley
da301ac6a0 subrepo: add tests for svn rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 16:44:17 -07:00
Sean Farley
f904aef7aa subrepo: add tests for hg rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 16:04:44 -07:00
Sean Farley
ea5a6b2798 push: add tests for unsafe ssh url (SEC) 2017-07-31 14:40:28 -07:00
Sean Farley
616cd64fcf pull: add tests for unsafe ssh url (SEC) 2017-07-28 16:47:32 -07:00
Sean Farley
ee608897f9 clone: add tests for unsafe ssh url (SEC) 2017-07-28 16:36:36 -07:00
Sean Farley
e199b92002 sshpeer: check for safe ssh url (SEC)
Checking in the sshpeer for a rogue ssh:// urls seems like the right
place to do it (instead of whack-a-mole with pull, clone, push, etc).
2017-08-01 14:40:19 -07:00
Augie Fackler
5f2d0af8a2 ssh: ban any username@host or host that starts with - (SEC)
This paranoia probably isn't required, but it can't hurt either.
2017-08-04 14:00:03 -04:00
Sean Farley
608ad9eb9e util: add utility method to check for bad ssh urls (SEC)
Our use of SSH has an exploit that will parse the first part of an url
blindly as a hostname. Prior to this set of security patches, a url
with '-oProxyCommand' could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' can be abused to execute
arbitrary commands in a similar fashion.

We defend against this by checking ssh:// URLs and looking for a
hostname that starts with a - or contains a |.

When this happens, let's throw a big abort into the user's face so
that they can inspect what's going on.
2017-07-28 16:32:25 -07:00
Yuya Nishihara
ba69ca47d4 pathauditor: disable cache of audited paths by default (issue5628)
The initial attempt was to discard cache when appropriate, but it appears
to be error prone. We had to carefully inspect all places where audit() is
called e.g. without actually updating filesystem, before removing files and
directories, etc.

So, this patch disables the cache of audited paths by default, and enables
it only for the following cases:

 - short-lived auditor objects
 - repo.vfs, repo.svfs, and repo.cachevfs, which are managed directories
   and considered sort of append-only (a file/directory would never be
   replaced with a symlink)

There would be more cacheable vfs objects (e.g. mq.queue.opener), but I
decided not to inspect all of them in this patch. We can make them cached
later.

Benchmark result:

- using old clone of http://selenic.com/repo/linux-2.6/ (38319 files)
- on tmpfs
- run HGRCPATH=/dev/null hg up -q --time tip && hg up -q null
- try 4 times and take the last three results

original:
real 7.480 secs (user 1.140+22.760 sys 0.150+1.690)
real 8.010 secs (user 1.070+22.280 sys 0.170+2.120)
real 7.470 secs (user 1.120+22.390 sys 0.120+1.910)

clearcache (the other series):
real 7.680 secs (user 1.120+23.420 sys 0.140+1.970)
real 7.670 secs (user 1.110+23.620 sys 0.130+1.810)
real 7.740 secs (user 1.090+23.510 sys 0.160+1.940)

enable cache only for vfs and svfs (this series):
real 8.730 secs (user 1.500+25.190 sys 0.260+2.260)
real 8.750 secs (user 1.490+25.170 sys 0.250+2.340)
real 9.010 secs (user 1.680+25.340 sys 0.280+2.540)

remove cache function at all (for reference):
real 9.620 secs (user 1.440+27.120 sys 0.250+2.980)
real 9.420 secs (user 1.400+26.940 sys 0.320+3.130)
real 9.760 secs (user 1.530+27.270 sys 0.250+2.970)
2017-07-26 22:10:15 +09:00
Yuya Nishihara
116bb6f6f9 tests: show cache of audited paths is never invalidated 2017-08-01 21:03:25 +09:00
Augie Fackler
25ec33c0a4 stable: merge heads 2017-08-10 14:23:25 -04:00
Augie Fackler
1003d2c0a9 Added signature for changeset 525f2b18248f 2017-08-10 14:14:49 -04:00
Augie Fackler
fa0eb2f7c3 Added signature for changeset 9ab2705099b9 2017-08-10 13:29:09 -04:00
Yuya Nishihara
62967cdb51 ssh: unban the use of pipe character in user@host:port string
This vulnerability was fixed by the previous patch and there were more ways
to exploit than using '|shellcmd'. So it doesn't make sense to reject only
pipe character.

Test cases are updated to actually try to exploit the bug. As the SSH bridge
of git/svn subrepos are not managed by our code, the tests for non-hg subrepos
are just removed.

This may be folded into the original patches.
2017-08-07 22:22:28 +09:00
Mathias De Maré
cafe7e372c chg: define _GNU_SOURCE to allow CentOS 5 compilation
Without this flag, compilation fails with:
 hgclient.c: In function 'hgc_open':
 hgclient.c:466: error: 'O_DIRECTORY' undeclared (first use in this function)
 hgclient.c:466: error: (Each undeclared identifier is reported only once
 hgclient.c:466: error: for each function it appears in.)

Differential Revision: https://phab.mercurial-scm.org/D260
2017-08-07 13:40:36 +02:00
Mathias De Maré
744ba88ca3 centos5: use vault urls
CentOS 5 has reached end-of-life. A working build for it is still
possible using 'vault.centos.org'.

Differential Revision: https://phab.mercurial-scm.org/D261
2017-08-07 13:38:25 +02:00
Kostia Balytskyi
edfeaa5101 ui: make sure buffer is flushed before waiting for user input (issue5587)
Without this patch on Windows 'hg ci -i' hangs waiting for user input
and "examine changes to 'file'? [Ynesfdaq?]" is never displayed (at least
if the diff is sufficiently small). When Ctrl+C is pressed, this prompt
becomes visible, which suggests that the buffer just wasn't flushed.
I've never seen this happening on Linux, but this looks harmless enough
to not platform-gate it.
2017-08-05 13:19:09 -07:00
Jun Wu
6b28fe8df7 ssh: quote parameters using shellquote (SEC)
This patch uses shellquote to quote ssh parameters more strictly to avoid
shell injection.
2017-08-04 23:54:12 -07:00
Yuya Nishihara
caba95785d util: fix sortdict.update() to call __setitem__() on PyPy (issue5639)
It appears that overriding __setitem__() doesn't work as documented on PyPy.
Let's patch it as before e5e7b1586953.

https://docs.python.org/2/library/collections.html#ordereddict-examples-and-recipes

The issue was ui.configitems() wasn't ordered correctly, so the pull command
was wrapped in different order.
2017-08-02 22:51:19 +09:00
Yuya Nishihara
c94a7a8e9e test-revlog-raw: close file handles explicitly (issue5644) 2017-08-02 22:58:38 +09:00
Yuya Nishihara
7e9483b814 tests: clear __pycache__ for PyPy compatibility (issue5638) (issue5642) 2017-08-02 22:04:02 +09:00
Yuya Nishihara
45be99c80d test-extension: glob module name in error message for PyPy 2017-08-02 22:06:45 +09:00
Yuya Nishihara
4be878f7d2 rebase: sort collapsed revisions in commit message (issue5643)
This fixes the test instability.
2017-08-02 21:52:22 +09:00
FUJIWARA Katsunori
cfbdc0a924 i18n: use actual filename, in which function is defined, for hg.pot
Before this patch, source filename for msgid in hg.pot file becomes
incorrect, if a function is defined in file A, but detected in dict in
file B,

For example, almost all debug* commands are defined in
debugcommands.py, but hggettext detects them in "table" of
commands.py. Therefore, docstring fragments of debug* commands are
marked as "defined in commands.py" in hg.pot file.

This is serious problem for translation, because the cost to find out
original location of texts increases very much.
2017-08-02 00:02:11 +09:00
FUJIWARA Katsunori
af39ee1c25 ui: enable pager always for explicit --pager=on (issue5580)
Before this patch, explicit --pager=on is unintentionally ignored by
any disabling factor, even if priority of it is less than --pager=on
(e.g. "[ui] paginate = off").
2017-08-01 18:52:52 +09:00
Sean Farley
d2e211e766 subrepo: add tests for git rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 14:55:11 -07:00
Sean Farley
43f1ebbcd6 subrepo: add tests for svn rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 16:44:17 -07:00
Sean Farley
8604805d42 subrepo: add tests for hg rogue ssh urls (SEC)
'ssh://' has an exploit that will pass the url blindly to the ssh
command, allowing a malicious person to have a subrepo with
'-oProxyCommand' which could run arbitrary code on a user's machine. In
addition, at least on Windows, a pipe '|' is able to execute arbitrary
commands.

When this happens, let's throw a big abort into the user's face so that
they can inspect what's going on.
2017-07-31 16:04:44 -07:00
Sean Farley
93ca65361f push: add tests for unsafe ssh url (SEC) 2017-07-31 14:40:28 -07:00
FUJIWARA Katsunori
d165bc820a README: make paragraphs before example code end with "::" for reST syntax
After this patch, README as reST text can be rendered into HTML more
appropriately. This is useful for hosting servers, which render README
file as a part of index HTML of its directory (for example,
Bitbucket).
2017-07-31 21:47:53 +09:00
Martin von Zweigbergk
9ce4ef597c commit: don't let failed commit with --addremove update dirstate (issue5645)
Differential Revision: https://phab.mercurial-scm.org/D204
2017-07-31 14:54:57 -07:00
Martin von Zweigbergk
ff40788359 tests: demonstrate that failed "hg ci -A" updates dirstate (issue5645)
Differential Revision: https://phab.mercurial-scm.org/D203
2017-07-31 14:54:08 -07:00
Martin von Zweigbergk
cc478f84d6 tests: fix test-flagprocessor.t flakiness
The test for duplicate flag processors depended on the timestamps
being set in the dirstate to work. If the time between the the
previous failed commit (which would set the timestamp, due to bug
5645) and the attempted commit with the duplicate flag processors was
small enough, it would fail. The failure was caused by a call to
commands.status() early in the commit process. If the dirstate did not
have the timestamp set, it would need to fetch the file content to
compare with. Since two flag processors had been registered, it would
attempted to base64 decode the contents twice, which would of course
fail.

This patch adds a "hg debugrebuilddirstate" to make it deterministic
and also replaces the test case's "hg commit" by simply "hg status",
since that will trigger reading of the contents and thereby use of the
flag processors as noted above.

Differential Revision: https://phab.mercurial-scm.org/D202
2017-07-31 16:32:01 -07:00
Martin von Zweigbergk
d9637ae740 tests: clarify that duplicate flag processors is not an error
The flag processors test for duplicate processors for a single flag
was misleading because the file from the previous test case caused it
to fail (making the "echo 'this should fail' > file" part
irrelevant). Let's remove the leftover from the previous test case to
make it clear that duplicate flag processors results only in a
warning.

Note that duplicate flag processors would have resulted in a failure
(not just a warning) until b319e3173a95 (extensions: catch uisetup and
extsetup failures and don't let them break hg, 2017-06-06). I remember
expressing my concern about ending up with half-loaded extensions. It
would be pretty unfortunate to have double-encoded revlog content
enter a repo, so maybe we should reconsider?

Differential Revision: https://phab.mercurial-scm.org/D201
2017-07-31 16:40:31 -07:00
FUJIWARA Katsunori
ac4ce63a67 tests: avoid unexpected result at invocation of *.py file on Windows
Invocation of "diff tool.py" in test-extdiff.t tests whether
shellquote() is applied on specified command as expected.

But direct invocation of "*.py" file might cause unexpected result on
Windows according to suffix binding.

For example, starting IDE, showing dialog to choose program to be
used, and so on. In such case, running test-extdiff.t is easily timed
out.

This patch uses intermediate *.bat file on Windows, to avoid such
unexpected result. Naming that intermediate file as "diff tool.bat" is
enough to test applying shellquote().
2017-08-01 01:27:32 +09:00
FUJIWARA Katsunori
b9e9255ab9 tests: use pdiff instead of diff for portability
"diff" command might cause redundant message, "No differences
encountered" on Solaris for example. But suppressing option like "-q"
isn't portable, because POSIX specification doesn't define it.

pdiff script was introduced by f4cba8b2e7b4 to stabilize output of
standard diff command on each platforms.
2017-07-31 13:16:34 +09:00
FUJIWARA Katsunori
898fb03733 tests: make pdiff return appropriate exit code at comparison of files
Before this patch, pdiff script returns 0, even if diff is detected.

This issue doesn't cause failure of tests using it, if it is invoked
via extdiff extension, because extdiff itself examines changes between
specified revisions and decides exit code.

BTW, this patch ignores recursive comparison case, because:

  - there is no portable way for current while-read based
    implementation to return 1 at detecting changes

  - it isn't yet needed to replace direct "diff -r" invocation by
    pdiff for portability
2017-07-31 13:10:19 +09:00
Martin von Zweigbergk
255c4290a2 tests: make test-profile.t pass if statprof didn't collect samples
We had the first 3 tests in test-profile.t fail because the output
didn't match. I have not yet confirmed that this was because no
samples were collected, but we shouldn't require samples to be
collected for the test to pass either way.

Differential Revision: https://phab.mercurial-scm.org/D199
2017-07-31 12:43:26 -07:00
Sean Farley
d4c4dd7bc9 pull: add tests for unsafe ssh url (SEC) 2017-07-28 16:47:32 -07:00
Sean Farley
8f38da87d6 clone: add tests for unsafe ssh url (SEC) 2017-07-28 16:36:36 -07:00