Check permissions when resolving accounts by secondary emails

The ByEmail searcher in AccountResolver resolved secondary emails
without checking whether the user has the Modify Account capability that
is required for being able to see secondary emails of other users.

Due to this it was possible to:
* Resolve a non-visible secondary email through the accounts API, e.g.:
  GET /accounts/<seondary-email>/detail
* Query changes by a non-visible secondary email, e.g query changes that
  are owned/uploaded/reviewed by the account that owns the secondary
  email.

The visibility of the resolved accounts is checked in both cases, so
resolving a non-visible secondary email only worked when the account
owning it was visible.

A partial fix for the same issue had already been done by change
Ic0f36127a, but this fix missed to check the permission in the ByEmail
searcher (the ByEmail searcher is only used if the input contains '@',
hence the tests that were added by the fix change didn't catch this).

With this change AccountResolver resolves secondary emails for other
accounts only if the user has the Modify Account capability. Secondary
emails of the own account are always visible and hence always resolved.

Release-Notes: Check permissions when resolving accounts by secondary emails
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I799bf1c57eb84549cba6d7ff462c04cef90fc63b
Signed-off-by: Edwin Kempin <ekempin@google.com>
4 files changed
tree: f4bfbca0565d017deb1cfdaa1335390b32de97bd
  1. .settings/
  2. .ts-out/
  3. antlr3/
  4. contrib/
  5. Documentation/
  6. e2e-tests/
  7. java/
  8. javatests/
  9. lib/
  10. modules/
  11. plugins/
  12. polygerrit-ui/
  13. prolog/
  14. prologtests/
  15. proto/
  16. resources/
  17. tools/
  18. webapp/
  19. .bazelignore
  20. .bazelproject
  21. .bazelrc
  22. .bazelversion
  23. .editorconfig
  24. .git-blame-ignore-revs
  25. .gitignore
  26. .gitmodules
  27. .gitreview
  28. .mailmap
  29. .pydevproject
  30. .zuul.yaml
  31. BUILD
  32. COPYING
  33. INSTALL
  34. Jenkinsfile
  35. package.json
  36. README.md
  37. SUBMITTING_PATCHES
  38. version.bzl
  39. web-dev-server.config.mjs
  40. WORKSPACE
  41. yarn.lock
README.md

Gerrit Code Review

Gerrit is a code review and project management tool for Git based projects.

Build Status Maven Central

Objective

Gerrit makes reviews easier by showing changes in a side-by-side display, and allowing inline comments to be added by any reviewer.

Gerrit simplifies Git based project maintainership by permitting any authorized user to submit changes to the master Git repository, rather than requiring all approved changes to be merged in by hand by the project maintainer.

Documentation

For information about how to install and use Gerrit, refer to the documentation.

Source

Our canonical Git repository is located on googlesource.com. There is a mirror of the repository on Github.

Reporting bugs

Please report bugs on the issue tracker.

Contribute

Gerrit is the work of hundreds of contributors. We appreciate your help!

Please read the contribution guidelines.

Note that we do not accept Pull Requests via the Github mirror.

Getting in contact

The Developer Mailing list is repo-discuss on Google Groups.

License

Gerrit is provided under the Apache License 2.0.

Build

Install Bazel and run the following:

    git clone --recurse-submodules https://gerrit.googlesource.com/gerrit
    cd gerrit && bazel build release

Install binary packages (Deb/Rpm)

The instruction how to configure GerritForge/BinTray repositories is here

On Debian/Ubuntu run:

    apt-get update && apt-get install gerrit=<version>-<release>

NOTE: release is a counter that starts with 1 and indicates the number of packages that have been released with the same version of the software.

On CentOS/RedHat run:

    yum clean all && yum install gerrit-<version>[-<release>]

On Fedora run:

    dnf clean all && dnf install gerrit-<version>[-<release>]

Use pre-built Gerrit images on Docker

Docker images of Gerrit are available on DockerHub

To run a CentOS 8 based Gerrit image:

    docker run -p 8080:8080 gerritcodereview/gerrit[:version]-centos8

To run a Ubuntu 20.04 based Gerrit image:

    docker run -p 8080:8080 gerritcodereview/gerrit[:version]-ubuntu20

NOTE: release is optional. Last released package of the version is installed if the release number is omitted.