Commit Graph

66 Commits

Author SHA1 Message Date
GitLab Bot 4fd77e112f Add latest changes from gitlab-org/gitlab@master 2020-11-05 00:09:16 +00:00
GitLab Bot 8a902a9508 Add latest changes from gitlab-org/gitlab@master 2020-10-22 03:08:25 +00:00
GitLab Bot b6724a211e Add latest changes from gitlab-org/gitlab@master 2020-10-07 06:09:03 +00:00
GitLab Bot 692f4b734f Add latest changes from gitlab-org/gitlab@master 2020-09-03 21:08:18 +00:00
GitLab Bot f2eb66fef8 Add latest changes from gitlab-org/gitlab@master 2020-08-21 03:10:16 +00:00
GitLab Bot 71da5de44f Add latest changes from gitlab-org/gitlab@master 2020-08-05 15:09:59 +00:00
GitLab Bot c4844aea3f Add latest changes from gitlab-org/gitlab@master 2020-06-03 00:08:38 +00:00
GitLab Bot 6c577c9ada Add latest changes from gitlab-org/gitlab@master 2020-05-25 03:08:11 +00:00
GitLab Bot 9bded6fb22 Add latest changes from gitlab-org/gitlab@master 2020-05-20 06:08:06 +00:00
GitLab Bot 2e4dcef627 Add latest changes from gitlab-org/gitlab@master 2020-05-08 15:09:28 +00:00
GitLab Bot 17c8111494 Add latest changes from gitlab-org/gitlab@master 2020-05-07 21:09:26 +00:00
GitLab Bot cfaf1cca44 Add latest changes from gitlab-org/gitlab@master 2020-02-16 21:08:53 +00:00
GitLab Bot e4ea43b2b8 Add latest changes from gitlab-org/gitlab@master 2020-01-27 21:08:47 +00:00
Markus Koller 49c83155cc
Load search result counts asynchronously
Querying all counts for the different search results in the same request
led to timeouts, so we now only calculate the count for the *current*
search results, and request the others in separate asynchronous calls.
2019-08-12 22:01:15 +02:00
Yorick Peterse a4e13a5966
Backport EE changes to ProjectSearchResults
EE made some changes to the project_ids_relation method, but these were
not backported to CE.
2019-08-08 13:34:07 +02:00
Patrick Derichs 0e99daae4a Use NotesFinder in IssuableActions module
Remove project from NotesFinder constructor

Add project parameter to specs

Also look for methods in private scope

Fix specs to match new NotesFinder constructor
2019-08-01 10:42:42 +02:00
Felipe Artur b70b43d07e Resolve: Milestones leaked via search API
Fix milestone titles being leaked using search API
when users cannot read milestones
2019-05-20 11:08:34 -03:00
Francisco Javier López 68e533dc21 Add improvements to the global search process
Removed the conditions added to
Project.with_feature_available_for_user, and moved to the
IssuableFinder. Now, we ensure that, in the projects retrieved
in the Finder, the user has enough access for the feature.
2019-05-07 11:08:25 +00:00
Alexis Reigel 241f38b01d
project's user search includes group members too 2019-03-14 18:21:02 +01:00
Alexis Reigel 22f44b50d8
add users search results to project scoped search 2019-03-14 18:16:03 +01:00
Jan Provaznik 58bfd73331 Optimized file search to work without limits
* removed 100 limit on file search results because we
  load all results anyway
* expensive processing (parsing match content, utf encoding)
  is done only for selected page in paginated output
2018-12-06 09:25:09 +01:00
Mark Chao a4ba973e24 Allow FoundBlob to access language from gitattributes
Extract language_from_git_attributes as a concern so it can
ben included in two blob classes.
2018-10-30 15:44:55 +08:00
gfyoung c858f70d07 Enable frozen string for lib/gitlab/*.rb 2018-10-22 07:00:50 +00:00
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Francisco Javier López 6354d55470 Fixing bug with wiki ref in ProjectSearchResults 2018-07-20 13:49:30 +00:00
Francisco Javier López 7350eb1fa8 Add ability to search wiki titles 2018-06-04 11:41:37 +00:00
Jan Provaznik 91f8656c2c Disable greedy mode when matching filename 2018-05-15 10:20:18 +00:00
Jasper Maes d17d3ec7f7 Split repository search result on \n instead of $ to prevent the items of the array to start with a newline. Remove the strip from parsing the search result to keep result endlines. 2018-03-19 19:09:31 +01:00
Jan Provaznik 741caf93e1 Use limited count queries also for scoped searches 2018-03-05 13:25:56 +00:00
Jarka Kadlecová b0b4ae1875 API - Include project in commits&blobs search results 2018-02-14 09:00:26 +01:00
Jarka Kadlecová 1b2400b529 Return only limited pagination headers for search API endpoints 2018-02-06 17:58:18 +01:00
Jarka Kadlecová 7381944565 Support search in API 2018-02-06 16:02:02 +01:00
Jan Provaznik 090ca9c33e Use limit for search count queries
Search query is especially slow if a user searches a generic string
which matches many records, in such case search can take tens of
seconds or time out. To speed up the search query, we search only for
first 1000 records, if there is >1000 matching records we just display
"1000+" instead of precise total count supposing that with such amount
the exact count is not so important for the user.

Because for issues even limited search was not fast enough, 2-phase
approach is used for issues: first we use simpler/faster query to get
all public issues, if this exceeds the limit, we just return the limit.
If the amount of matching results is lower than limit, we re-run more
complex search query (which includes also confidential issues).
Re-running the complex query should be fast enough in such case because the
amount of matching issues is lower than limit.

Because exact total_count is now limited, this patch also switches to
to "prev/next" pagination.

Related #40540
2018-01-23 22:33:42 +01:00
Sean McGivern 82f4564fb7 Fix project search results for digits surrounded by colons
A file containing /:\d+:/ in its contents would break the search results if
those contents were part of the results, because we were splitting on colons,
which can't work with untrusted input.

Changing to use the null byte as a separator is much safer.
2018-01-16 11:56:07 +00:00
haseeb 869877ab26 fix for special charecter in file names 2017-11-30 09:57:58 +00:00
Valery Sizov f6c4ccd1f2 Backport FileFinder from EE 2017-05-12 13:21:30 +03:00
Douwe Maan 61a81a3ac2 Merge branch '31157-respect-project-features-in-wiki-search' into 'security'
Respect project features in wiki and blob search

See merge request !2089
2017-05-10 16:44:20 +02:00
Nick Thomas 7f32ad7097 Fix blob highlighting in search 2017-04-03 18:51:44 +01:00
YarNayar 99404a5851 Search feature: redirects to commit page if query is commit sha and only commit found
See !8028 and #24833
2017-01-24 14:58:00 +03:00
YarNayar dd3ddcd72b Allows to search within project by commit's hash
Was proposed in #24833
2017-01-24 14:56:00 +03:00
Douwe Maan 12db4cc0e7 Merge branch 'jej-note-search-uses-finder' into 'security'
Fix missing Note access checks in by moving Note#search to updated NoteFinder

Split from !2024 to partially solve https://gitlab.com/gitlab-org/gitlab-ce/issues/23867

## Which fixes are in this MR?

⚠️ - Potentially untested  
💣 - No test coverage  
🚥 - Test coverage of some sort exists (a test failed when error raised)  
🚦 - Test coverage of return value (a test failed when nil used)  
 - Permissions check tested

### Note lookup without access check

- [x]  app/finders/notes_finder.rb:13 :download_code check
- [x]  app/finders/notes_finder.rb:19 `SnippetsFinder`
- [x]  app/models/note.rb:121 [`Issue#visible_to_user`]
- [x]  lib/gitlab/project_search_results.rb:113
  - This is the only use of `app/models/note.rb:121` above, but importantly has no access checks at all. This means it leaks MR comments and snippets when those features are `team-only` in addition to the issue comments which would be fixed by `app/models/note.rb:121`.
  - It is only called from SearchController where `can?(current_user, :download_code, @project)` is checked, so commit comments are not leaked.

### Previous discussions
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b915c5267a63628b0bafd23d37792ae73ceae272_13_13 `: download_code` check on commit
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b915c5267a63628b0bafd23d37792ae73ceae272_19_19 `SnippetsFinder` should be used
  - `SnippetsFinder` should check if the snippets feature is enabled -> https://gitlab.com/gitlab-org/gitlab-ce/issues/25223

###  Acceptance criteria met?
- [x] Tests added for new code
- [x] TODO comments removed
- [x] Squashed and removed skipped tests
- [x] Changelog entry
- [ ] State Gitlab versions affected and issue severity in description
- [ ] Create technical debt issue for NotesFinder.
  - Either split into `NotesFinder::ForTarget` and `NotesFinder::Search` or consider object per notable type such as `NotesFinder::OnIssue`. For the first option could create `NotesFinder::Base` which is either inherited from or which can be included in the other two.
  - Avoid case statement anti-pattern in this finder with use of `NotesFinder::OnCommit` etc. Consider something on the finder for this? `Model.finder(user, project)`
  - Move `inc_author` to the controller, and implement `related_notes` to replace `non_diff_notes`/`mr_and_commit_notes`

See merge request !2035
2016-12-15 11:40:12 -03:00
Valery Sizov a5632e802b Search for a filename in a project 2016-11-16 14:25:54 +02:00
Valery Sizov 869696bca3 Faster search 2016-11-08 14:21:19 +02:00
Valery Sizov fd2c3a3da0 Refactoring find_commits functionality 2016-10-20 12:45:34 +03:00
Valery Sizov 03bed0fbd3 Clean up search result classes 2016-09-06 10:12:55 +03:00
Valery Sizov 9154586ce5 Confidential notes data leak 2016-05-31 21:32:53 +03:00
Douglas Barbosa Alexandre f2ba4e3d36 Restrict access to confidential issues on search results 2016-03-17 20:55:59 -03:00
Yorick Peterse 8c2868e8ea Added ProjectSearchResults#project_ids_relation
This ensures some other methods such as the "issues" method still work.
2016-03-11 15:25:23 -05:00
Yorick Peterse ec349dc1b6 Refactor Gitlab::ProjectSearchResults
Previously this class would be given a project ID which was then used to
retrieve the corresponding Project object. However, in all cases the
Project object was already known as it was used to grab the ID to pass
to ProjectSearchResults. By just passing a Project instead we remove the
need for an extra query as well as the need for some other complexity
in this class.
2016-03-11 15:25:22 -05:00
Dmitriy Zaporozhets 28f6fba97c
Fix commits search for empty repository
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-11-03 10:16:09 +01:00