Skip to content

Allow users with read_code permission to search code

mo khan requested to merge mokhax/421024/read-code-search into master

What does this MR do and why?

Users associated with a custrom role with the read_code permission should be able to search for results in code. This change fixes a defect that prevented users with the read_code permission from searching (via elasticsearch) through code that they should have access to.

#421024 (closed)

Screenshots

Before After
image image

Project search via Zoekt:

image

Group search via Zoekt is disabled because of #389750 (closed).

image

How to set up and validate locally

  1. Enable elastic search.
    • gdk config set elasticsearch.enabled true && gdk reconfigure && gdk restart
    • bundle exec rake gitlab:elastic:index
  2. Enable the search_filter_by_ability feature flag. (e.g. Feature.enable(:search_filter_by_ability))
  3. Create a custom role with :read_code enabled.
  4. Invite a user to a group with the role created in the previous step.
  5. Login as the new user.
  6. Search for code at the group level.
  7. Verify that search results are shown.

To test with Zoekt, enable Zoekt and then repeat the steps above.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by mo khan

Merge request reports

Loading