gitlab-org--gitlab-foss/spec/models
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
..
ci Fix detailed status specs for pipeline stage model 2016-12-12 15:40:28 +01:00
concerns Merge branch 'seed-runner-token' into 'master' 2016-12-15 11:12:29 +00:00
cycle_analytics Merge branch 'jej-fix-missing-access-check-on-issues' into 'security' 2016-11-28 21:25:46 -03:00
hooks Remove schema annotations completely 2016-09-16 14:37:48 +03:00
issue Add a be_like_time matcher and use it in specs 2016-10-17 14:44:20 +01:00
members Optimize Event queries by removing default order 2016-10-27 20:07:11 -03:00
merge_request Add a be_like_time matcher and use it in specs 2016-10-17 14:44:20 +01:00
network Fix Error 500 resulting when loading network graph 2016-08-20 09:57:20 -07:00
project_services Merge branch 'fix-slack-pipeline-message-by-api' into 'master' 2016-12-15 11:08:45 +00:00
ability_spec.rb Project tools visibility level 2016-09-01 11:47:59 -03:00
abuse_report_spec.rb Add markdown cache columns to the database, but don't use them yet 2016-10-07 02:54:25 +01:00
appearance_spec.rb Use build instead create record in appearance_spec 2016-10-12 10:50:01 +05:00
application_setting_spec.rb Refine Git garbage collection 2016-11-04 14:30:11 +01:00
award_emoji_spec.rb
blob_spec.rb Handle encoding in non-binary Blob instances 2016-09-14 14:15:31 +02:00
board_spec.rb The lists: Backlog, and Done cannot be destroyed 2016-08-17 12:58:57 -03:00
broadcast_message_spec.rb Use build instead create in BroadcastMessage model spec 2016-11-19 03:22:02 +05:00
build_spec.rb Merge branch '22849-ci-build-ref-slug' into 'master' 2016-12-15 11:08:27 +00:00
chat_name_spec.rb Add most of specs for chat names 2016-11-17 21:34:23 +01:00
commit_range_spec.rb Merge branch 'jej-23867-use-mr-finder-instead-of-access-check' into 'security' 2016-12-08 21:42:07 -03:00
commit_spec.rb Merge branch 'jej-23867-use-mr-finder-instead-of-access-check' into 'security' 2016-12-08 21:42:07 -03:00
commit_status_spec.rb Add some missing tests for detailed status methods 2016-12-14 10:21:16 +01:00
compare_spec.rb switch from diff_file_collection to diffs 2016-08-03 07:00:20 +02:00
deploy_key_spec.rb Remove unused lets from deploy_key spec 2016-10-12 10:46:30 +05:00
deploy_keys_project_spec.rb
deployment_spec.rb Work on specs 2016-10-17 17:10:26 +02:00
diff_note_spec.rb Optimize discussion notes resolving and unresolving 2016-09-06 12:14:09 -03:00
discussion_spec.rb Feature: delegate all open discussions to Issue 2016-12-05 20:55:45 +01:00
email_spec.rb refactor(email): use setter method instead AR callbacks 2016-10-23 17:30:07 +05:00
environment_spec.rb Use :maximum instead of :within for length validators with a 0..N range 2016-12-06 10:23:17 +01:00
event_spec.rb Removed data-user-is view code 2016-11-25 13:45:34 +01:00
external_issue_spec.rb Add the method ExternalIssue#project_id 2016-11-07 12:49:24 +01:00
forked_project_link_spec.rb Enforce the fork_project permission in Projects::CreateService 2016-09-27 13:17:56 +01:00
generic_commit_status_spec.rb Add some missing tests for detailed status methods 2016-12-14 10:21:16 +01:00
global_milestone_spec.rb Ensure milestones passed to GlobalMilestone is an ActiveRecord::Relation 2016-09-23 13:34:39 +02:00
group_label_spec.rb Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
group_spec.rb Merge branch 'master' into 'dz-remove-namespaces-path-uniq' 2016-12-14 15:18:46 +00:00
guest_spec.rb Merge branch 'fix-unathorized-cloning' into 'security' 2016-11-09 12:27:17 +01:00
identity_spec.rb
issue_collection_spec.rb Process commits in a separate worker 2016-11-07 13:11:44 +01:00
issue_spec.rb Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
key_spec.rb Use :maximum instead of :within for length validators with a 0..N range 2016-12-06 10:23:17 +01:00
label_link_spec.rb Build instead create in label_link model spec 2016-10-11 10:58:46 +05:00
label_priority_spec.rb Add support to group labels prioritization on project level 2016-10-19 14:58:27 -02:00
label_spec.rb Abstract LabelPriority away into methods on Label model 2016-10-19 14:58:27 -02:00
legacy_diff_note_spec.rb Store discussion_id on Note for faster discussion lookup. 2016-08-17 12:16:46 -05:00
list_spec.rb Add a movable scope and a movable? method to List model 2016-08-17 12:58:59 -03:00
member_spec.rb Precalculate user's authorized projects in database 2016-11-18 20:25:45 +02:00
merge_request_diff_spec.rb Replace references to MergeRequestDiff#commits with st_commits 2016-12-01 12:17:30 +01:00
merge_request_spec.rb Merge branch 'jej-note-search-uses-finder' into 'security' 2016-12-15 11:40:12 -03:00
milestone_spec.rb Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
namespace_spec.rb Modify namespace name and path validation 2016-12-12 14:21:02 +02:00
note_spec.rb Merge branch 'jej-note-search-uses-finder' into 'security' 2016-12-15 11:40:12 -03:00
notification_setting_spec.rb
personal_access_token_spec.rb
project_feature_spec.rb Add visibility level to project repository 2016-10-17 18:12:18 -02:00
project_group_link_spec.rb Precalculate user's authorized projects in database 2016-11-18 20:25:45 +02:00
project_label_spec.rb Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
project_snippet_spec.rb
project_spec.rb Merge branch 'dz-nested-groups' into 'master' 2016-12-09 01:52:36 +00:00
project_team_spec.rb Update ProjectTeam#fetch_members to use project authorizations 2016-11-23 12:59:13 +02:00
project_wiki_spec.rb
protected_branch_spec.rb
release_spec.rb
repository_spec.rb Update outdated visible content spec descriptions 2016-12-07 11:31:01 +01:00
route_spec.rb Add nested groups support on data level 2016-12-08 11:47:16 +02:00
service_spec.rb Remove empty describe block in service spec 2016-11-22 21:27:16 +05:00
snippet_spec.rb Merge branch '25209-improve-length-validators' into 'master' 2016-12-07 10:31:21 +00:00
spam_log_spec.rb
subscription_spec.rb Allow subscriptions to be created without a project 2016-11-17 15:10:13 -02:00
todo_spec.rb
tree_spec.rb
trending_project_spec.rb Precalculate trending projects 2016-10-10 12:27:08 +02:00
user_agent_detail_spec.rb Further refactor and syntax fixes. 2016-08-15 17:20:57 -05:00
user_spec.rb Be smarter when finding a sudoed user in API::Helpers 2016-12-13 15:53:00 +01:00
wiki_page_spec.rb adds second batch of tests changed to active tense 2016-08-09 15:11:39 +01:00