4584: Mercurial: Exception in _get_outgoing_changesets() when repo has untrusted hgrc

gd-sfc

What version are you running?

RBTools 0.7.8

What steps will reproduce the problem?

  1. Configure a Mercurial repository with a .hg/hgrc file owned by an untrusted user (by default, anybody other than the user himself).
  2. Create an outgoing commit.
  3. Run rbt post .

What is the expected output? What do you see instead?

The commands should create a new review request. Instead, it fails with CRITICAL: need more than 1 value to unpack.

What operating system are you using?

Fedora 26 x86_64.

Attach the debug out from the command.

>>> RBTools 0.7.8
>>> Python 2.7.13 (default, Sep  5 2017, 08:53:59) 
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]
>>> Running on Linux-4.12.9-300.fc26.x86_64-x86_64-with-fedora-26-Twenty_Six
>>> Home = /home/gd
>>> Current directory = /home/gd/source/redacted
>>> Command line: rbt post -d .
>>> Checking for a Subversion repository...
>>> Running: svn --non-interactive info
>>> Command exited with rc 1: ['svn', '--non-interactive', u'info']
svn: E155007: '/home/gd/source/redacted' is not a working copy
---
>>> Checking for a Git repository...
>>> Running: git rev-parse --git-dir
>>> Command exited with rc 128: ['git', 'rev-parse', '--git-dir']
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
---
>>> Checking for a Mercurial repository...
>>> Running: hg root
>>> Running: hg showconfig
>>> Running: hg svn info
>>> Command exited with rc 255: [u'hg', u'svn', u'info']
hg: unknown command 'svn'
Mercurial Distributed SCM

basic commands:

 add           add the specified files on the next commit
 annotate      show changeset information by line for each file
 clone         make a copy of an existing repository
 commit        commit the specified files or all outstanding changes
 diff          diff repository (or selected files)
 export        dump the header and diffs for one or more changesets
 forget        forget the specified files on the next commit
 init          create a new repository in the given directory
 log           show revision history of entire repository or files
 merge         merge another revision into working directory
 pull          pull changes from the specified source
 push          push changes to the specified destination
 remove        remove the specified files on the next commit
 serve         start stand-alone webserver
 status        show changed files in the working directory
 summary       summarize working directory state
 update        update working directory (or switch revisions)

(use 'hg help' for the full list of commands or 'hg -v' for details)
---
>>> Using candidate path u'default': u'/project/hg/incoming/redacted'
>>> repository info: Path: /project/hg/incoming/redacted, Base path: , Supports changesets: False
>>> Making HTTP GET request to https://reviewboard.uk.redacted/api/
>>> Running: hg parents --hidden -r 0
>>> Running: hg identify -i --hidden -r . --config extensions.rbtoolsnormalize=/usr/lib/python2.7/site-packages/rbtools/helpers/hgext.py
>>> Running: hg parents --hidden -r 187b11ef5c7a --template {node|short} --config extensions.rbtoolsnormalize=/usr/lib/python2.7/site-packages/rbtools/helpers/hgext.py
>>> Running: hg -q outgoing --template {rev}\t{node|short}\t{branch}\n default -r 5dfc8cbfbc9d
>>> Command exited with rc 1: [u'hg', u'-q', u'outgoing', u'--template', u'{rev}\\t{node|short}\\t{branch}\\n', u'default', u'-r', u'5dfc8cbfbc9d']
not trusting file /project/hg/incoming/redacted/.hg/hgrc from untrusted user dr, group ci
---
Traceback (most recent call last):
  File "/usr/bin/rbt", line 11, in <module>
    load_entry_point('RBTools==0.7.8', 'console_scripts', 'rbt')()
  File "/usr/lib/python2.7/site-packages/rbtools/commands/main.py", line 133, in main
    command.run_from_argv([RB_MAIN, command_name] + args)
  File "/usr/lib/python2.7/site-packages/rbtools/commands/__init__.py", line 664, in run_from_argv
    exit_code = self.main(*args) or 0
  File "/usr/lib/python2.7/site-packages/rbtools/commands/post.py", line 735, in main
    self.revisions = get_revisions(self.tool, self.cmd_args)
  File "/usr/lib/python2.7/site-packages/rbtools/utils/review_request.py", line 66, in get_revisions
    revisions = tool.parse_revision_spec(cmd_args)
  File "/usr/lib/python2.7/site-packages/rbtools/clients/mercurial.py", line 279, in parse_revision_spec
    rev=result['base'])
  File "/usr/lib/python2.7/site-packages/rbtools/clients/mercurial.py", line 605, in _get_outgoing_changesets
    rev, node, branch = [f.strip() for f in line.split('\t')]
ValueError: need more than 1 value to unpack

Please provide any additional information below.

The untrusted hgrc file results in a message on stderr when running hg outgoing in _get_outgoing_changesets(), which the function then attempts to parse.

Thank you!

#1 gd-sfc

Correction: the untrusted hgrc file should be in the upstream repository, not in the clone.