Skip to content
Snippets Groups Projects
  1. Jul 03, 2016
  2. Jul 02, 2016
    • Gregory Szorc's avatar
      sslutil: don't attempt to find default CA certs file when told not to · 53b7fc7cc2bb
      Gregory Szorc authored
      Before, devel.disableloaddefaultcerts only impacted the loading of
      default certs via SSLContext. After this patch, the config option also
      prevents sslutil._defaultcacerts() from being called.
      
      This config option is meant to be used by tests to force no CA certs
      to be loaded. Future patches will enable _defaultcacerts() to have
      success more often. Without this change we can't reliably test the
      failure to load CA certs. (This patch also likely fixes test failures
      on some OS X configurations.)
      53b7fc7cc2bb
    • Gregory Szorc's avatar
      sslutil: pass ui to _defaultcacerts · 918dce4b8c26
      Gregory Szorc authored
      We'll use this shortly.
      918dce4b8c26
    • Gregory Szorc's avatar
      sslutil: change comment and logged message for found ca cert file · 4e72995f6c9c
      Gregory Szorc authored
      Future patches will change _defaultcacerts() to do something
      on platforms that aren't OS X. Change the comment and logged
      message to reflect the future.
      4e72995f6c9c
    • Gregory Szorc's avatar
      tests: better testing of loaded certificates · 5caa415aa48b
      Gregory Szorc authored
      Tests were failing on systems like RHEL 7 where loading the system
      certificates results in CA certs being reported to Python. We add
      a feature that detects when we're able to load *and detect* the
      loading of system certificates. We update the tests to cover the
      3 scenarios:
      
      1) system CAs are loadable and detected
      2) system CAs are loadable but not detected
      3) system CAs aren't loadable
      5caa415aa48b
  3. Jul 01, 2016
  4. Jun 21, 2016
    • Sean Farley's avatar
      histedit: move autoverb rule to the commit it matches · 2ff243c415b4
      Sean Farley authored
      Inspired by how 'git rebase -i' works, we move the autoverb to the
      commit line summary that it matches. We do this by iterating over all
      rules and inserting each non-autoverb line into a key in an ordered
      dictionary. If we find an autoverb line later, we then search for the
      matching key and append it to the list (which is the value of each key
      in the dictionary). If we can't find a previous line to move to, then we
      leave the rule in the same spot.
      
      Tests have been updated but the diff looks a little messy because we
      need to change one of the summary lines so that it will actually move to
      a new spot. On top of that, we added -q flags to future some of the
      output and needed to change the file it modified so that it wouldn't
      cause a conflict.
      2ff243c415b4
  5. May 27, 2016
  6. May 26, 2016
    • Sean Farley's avatar
      histedit: remove unneeded initial parameter · a0efbfbba7b5
      Sean Farley authored
      Now that the autoverb logic no longer acts on an individual rule line,
      we don't need this parameter since we apply our logic just once at the
      time of initialization.
      a0efbfbba7b5
    • Sean Farley's avatar
      histedit: move autoverb logic from torule to ruleeditor · 00d2bf4137e6
      Sean Farley authored
      This is needed for an upcoming change that will automatically rearrange the
      rules based on the commit message. Before this patch, the autoverb logic only
      applied to one rule at a time. This moves that logic one step up so that it can
      iterate over all the rules and rearrange as needed.
      00d2bf4137e6
  7. Jun 30, 2016
    • Martin von Zweigbergk's avatar
      treemanifests: actually strip directory manifests · 87c184c9bfef
      Martin von Zweigbergk authored
      Stripping has only partly worked since 7cbb3a01fa38 (repair: use cg3
      for treemanifests, 2016-01-19): the bundle seems to have been created
      correctly, but revlog entries in subdirectory revlogs were not
      stripped. This meant that e.g. "hg verify" would fail after stripping
      in a tree manifest repo.
      
      To find the revisions to strip, we simply iterate over all directories
      in the repo (included in store.datafiles()). This is inefficient for
      stripping few commits, but efficient for stripping many commits. To
      optimize for stripping few commits, we could instead walk the tree
      from the root and find modified subdirectories, just like we do in the
      changegroup code. I'm leaving that for another day.
      87c184c9bfef
    • Jun Wu's avatar
      logtoprocess: do not leak the ui object in uisetup · 4cf0542dcbe7
      Jun Wu authored
      logtoprocess.log should use "self" passed in function arguments instead
      of the "ui" object from outside the function.
      4cf0542dcbe7
  8. Jun 29, 2016
  9. Jun 30, 2016
  10. Jul 01, 2016
  11. Jun 28, 2016
    • Pulkit Goyal's avatar
      py3: conditionalize httplib import · 0c741fd6158a
      Pulkit Goyal authored
      The httplib library is renamed to http.client in python 3. So the
      import is conditionalized and a test is added in check-code to warn
      to use util.httplib
      0c741fd6158a
  12. Jul 01, 2016
  13. Jun 27, 2016
    • Gregory Szorc's avatar
      sslutil: synchronize hostname matching logic with CPython · 26a5d605b868
      Gregory Szorc authored
      sslutil contains its own hostname matching logic. CPython has code
      for the same intent. However, it is only available to Python 2.7.9+
      (or distributions that have backported 2.7.9's ssl module
      improvements).
      
      This patch effectively imports CPython's hostname matching code
      from its ssl.py into sslutil.py. The hostname matching code itself
      is pretty similar. However, the DNS name matching code is much more
      robust and spec conformant.
      
      As the test changes show, this changes some behavior around
      wildcard handling and IDNA matching. The new behavior allows
      wildcards in the middle of words (e.g. 'f*.com' matches 'foo.com')
      This is spec compliant according to RFC 6125 Section 6.5.3 item 3.
      
      There is one test where the matcher is more strict. Before,
      '*.a.com' matched '.a.com'. Now it doesn't match. Strictly speaking
      this is a security vulnerability.
      3.8.4
      26a5d605b868
    • Gregory Szorc's avatar
      tests: import CPython's hostname matching tests · 676f4d0e3a7b
      Gregory Szorc authored
      CPython has a more comprehensive test suite for it's built-in hostname
      matching functionality. This patch adds its tests so we can improve
      our hostname matching functionality.
      
      Many of the tests have different results from CPython. These will be
      addressed in a subsequent commit.
      676f4d0e3a7b
  14. Jul 01, 2016
  15. Jun 30, 2016
    • Gregory Szorc's avatar
      sslutil: emit warning when no CA certificates loaded · 5b71a8d7f7ff
      Gregory Szorc authored
      If no CA certificates are loaded, that is almost certainly a/the
      reason certificate verification fails when connecting to a server.
      
      The modern ssl module in Python 2.7.9+ provides an API to access
      the list of loaded CA certificates. This patch emits a warning
      on modern Python when certificate verification fails and there are
      no loaded CA certificates.
      
      There is no way to detect the number of loaded CA certificates
      unless the modern ssl module is present. Hence the differences
      in test output depending on whether modern ssl is available.
      
      It's worth noting that a test which specifies a CA file still
      renders this warning. That is because the certificate it is loading
      is a x509 client certificate and not a CA certificate. This
      test could be updated if anyone is so inclined.
      5b71a8d7f7ff
    • Gregory Szorc's avatar
      tests: test case where default ca certs not available · afbe1fe4c44e
      Gregory Szorc authored
      I'm not a fan of TLS tests not testing both branches of a possible
      configuration. While we have test coverage of the inability to validate
      a cert later in this file, I insist that we add this branch so
      our testing of security code is extra comprehensive.
      afbe1fe4c44e
    • Gregory Szorc's avatar
      sslutil: don't load default certificates when they aren't relevant · 13edc11eb7b7
      Gregory Szorc authored
      Before, we would call SSLContext.load_default_certs() when
      certificate verification wasn't being used. Since
      SSLContext.verify_mode == ssl.CERT_NONE, this would ideally
      no-op. However, there is a slim chance the loading of system
      certs could cause a failure. Furthermore, this behavior
      interfered with a future patch that aims to provide a more
      helpful error message when we're unable to load CAs.
      
      The lack of test fallout is hopefully a sign that our
      security code and tests are in a relatively good state.
      13edc11eb7b7
    • Gregory Szorc's avatar
      sslutil: display a better error message when CA file loading fails · 2f7f1e10f840
      Gregory Szorc authored
      Before, sslcontext.load_verify_locations() would raise a
      ssl.SSLError which would be caught further up the stack and converted
      to a urlerror. By that time, we lost track of what actually errored.
      
      Trapping the error here gives users a slightly more actionable error
      message.
      
      The behavior between Python <2.7.9 and Python 2.7.9+ differs. This
      is because our fake SSLContext class installed on <2.7.9 doesn't
      actually do anything during load_verify_locations: it defers actions
      until wrap_socket() time. Unfortunately, a number of errors can occur
      at wrap_socket() time and we're unable to ascertain what the root
      cause is. But that shouldn't stop us from providing better error
      messages to people running a modern and secure Python version.
      2f7f1e10f840
    • Gregory Szorc's avatar
      tests: add test for empty CA certs file · 072e4a595607
      Gregory Szorc authored
      smf reported that an environment with no loaded CA certs resulted
      in a weird error. I'd like to detect this a bit better so we can
      display an actionable error message.
      
      The actual error being globbed over in this patch is "unknown error"
      with a ssl.c line number. That isn't useful at all.
      072e4a595607
Loading