Commit Graph

74 Commits

Author SHA1 Message Date
Douwe Maan 3bf34face4 Merge branch 'jej-use-issuable-finder-instead-of-access-check' into 'security'
Replace issue access checks with use of IssuableFinder

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

### Issue lookup with access check

Using `visible_to_user` likely makes these security issues too. See [Code smells](#code-smells).

- [x] 🚦 app/finders/notes_finder.rb:15 [`visible_to_user`]
- [x] 🚥 app/views/layouts/nav/_project.html.haml:73 [`visible_to_user`] [`.count`]
- [x]  app/services/merge_requests/build_service.rb:84 [`issue.try(:confidential?)`]
- [x]  lib/api/issues.rb:112 [`visible_to_user`]
  - CHANGELOG: Prevented API returning issues set to 'Only team members' to everyone
- [x]  lib/api/helpers.rb:126 [`can?(current_user, :read_issue, issue)`] Maybe here too?
- [x]  lib/gitlab/search_results.rb:53 [`visible_to_user`]

### Previous discussions
- [ ] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b2ff264eddf9819d7693c14ae213d941494fe2b3_128_126
- [ ] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#7b6375270d22f880bdcb085e47b519b426a5c6c7_87_87

See merge request !2031
2016-11-28 21:26:23 -03:00
Douwe Maan 3d7704ae5f Merge branch 'zj-fix-label-creation-non-members' into 'security'
Fix label creation non members

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/23416

See merge request !2006
2016-11-28 21:24:19 -03:00
Rémy Coutable 81ba3f9177
API: Introduce `#find_group!` which also check access permission
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-24 16:58:32 +01:00
Douglas Barbosa Alexandre 0c052f116c Remove default value for `project` argument on subscribable concern 2016-11-17 15:10:13 -02:00
Sean McGivern 45fc8b73ed Fix API issues sorting 2016-09-09 16:10:01 +01:00
Robert Schilling 036cc8c27e API: Expose issue#confidential 2016-08-31 09:20:04 +02:00
tiagonbotelho 76c2901eac if issue is not valid we revert back to the old labels when updating 2016-08-30 18:39:03 +01:00
tiagonbotelho 7f0bcf0432 refactors update issue api request and some minor comments 2016-08-30 18:37:21 +01:00
tiagonbotelho b7d29ce659 adds test to check whether or not an email is sent to label subscribers after creating a new issue through the api 2016-08-30 18:37:21 +01:00
tiagonbotelho 7532c012c2 user is now notified when creating an issue through the api 2016-08-30 18:37:21 +01:00
Patricio Cano 43e756d4ea Refactored AkismetHelper into AkismetService and cleaned up `Spammable`
- Refactored SpamCheckService into SpamService
2016-08-15 13:18:15 -05:00
Patricio Cano 64ab2b3d9f Refactored spam related code even further
- Removed unnecessary column from `SpamLog`
- Moved creation of SpamLogs out of its own service and into SpamCheckService
- Simplified code in SpamCheckService.
- Moved move spam related code into Spammable concern
2016-08-15 13:18:15 -05:00
Patricio Cano 722fc84e3d Complete refactor of the `Spammable` concern and tests:
- Merged `AkismetSubmittable` into `Spammable`
- Clean up `SpamCheckService`
- Added tests for `Spammable`
- Added submit (ham or spam) options to `AkismetHelper`
2016-08-15 13:18:15 -05:00
Patricio Cano f01fce7f46 Refactor spam validation to a concern that can be easily reused and improve legibility in `SpamCheckService` 2016-07-26 19:29:16 -05:00
Patricio Cano 8f04cf0ead Refactor `SpamCheckService` to make it cleaner and clearer. 2016-07-26 15:18:07 -05:00
Patricio Cano f7807c5b68 Submit all issues on public projects to Akismet if enabled. 2016-07-26 15:17:52 -05:00
Patricio Cano 9c34fafb8b Submit new issues created via the WebUI by non project members to Akismet for spam check. 2016-07-26 15:17:41 -05:00
Robert Schilling e7d9fcc1c9 API: Expose due_date for issues 2016-07-12 17:59:21 +02:00
Marc Siegfriedt 6587feba65 gitlab-org/gitlab-ce#17818 - add api call for issues by group
rely only on IssuesFinder
docs and changelog
2016-06-23 16:31:48 +00:00
Alejandro Rodríguez fade1a4cde Fix pseudo n+1 queries with Note and Note Authors in issuables APIs
This was not a clear cut n+1 query, given that if you're directly subscribed to all issues
that the API is returning you never really need to check for the notes. However, if you're
subscribed to _all_ of them, then for each issuable you need to go once to `notes`, and
once to `users` (for the authors). By preemtively loading notes and authors, at worst you have
1 extra query, and at best you saved 2n extra queries. We also took advantage of this preloading
of notes when counting user notes.
2016-06-08 10:26:05 -04:00
Ahmad Sherif 0c22698bd4 Add API endpoints for un/subscribing from/to a label
Closes #15638
2016-05-12 22:48:09 +02:00
Stan Hu e99cf05875 Use ActionDispatch Remote IP for Akismet checking
Previously all remote IPs appeared at 127.0.0.1, which made Akismet
not very useful. Using the ActionDispatch Remote IP (http://api.rubyonrails.org/classes/ActionDispatch/RemoteIp.html)
should provide more reliable results.

Closes #16629
2016-04-27 22:12:55 -07:00
Michael Greene 28a7fe25fd Allow back dating issues on update 2016-04-13 12:04:09 -05:00
Robert Schilling a9200d93d3 Ensure that issues and merge requests are found 2016-04-13 17:15:42 +02:00
Robert Schilling fa3009095f Make subscription API more RESTful 2016-04-13 13:52:13 +02:00
Robert Schilling f875189b39 API: Ability to subscribe and unsubscribe from a merge request 2016-04-13 13:45:01 +02:00
Robert Schilling bd0be13f5b API: Ability to subscribe and unsubscribe from an issue 2016-04-13 13:45:00 +02:00
Robert Schilling 2b036025d6 Update tests for moving issues via API 2016-04-13 11:31:50 +02:00
Robert Schilling 482f67edb4 API: Ability to move an issue 2016-04-13 11:23:42 +02:00
Robert Schilling fb2fde9d62 API: Expose subscribed? on issues 2016-04-08 15:53:04 +02:00
Zeger-Jan van de Weg 473b261261 Back dating of issues when creating throught the API 2016-03-28 16:45:36 +02:00
Zeger-Jan van de Weg 3b088fc5b5 Minor improvements on IssuableActions 2016-03-21 16:59:35 +01:00
Zeger-Jan van de Weg 1d77822816 minor improvements and fixed specs 2016-03-19 21:24:05 +01:00
Zeger-Jan van de Weg 7342a4566c Dry destroy action on issuables 2016-03-19 21:24:05 +01:00
Zeger-Jan van de Weg 212e83bab3 Soft delete issuables 2016-03-19 21:23:03 +01:00
Douglas Barbosa Alexandre e4f1c001e6 Restrict access to confidential issues through API 2016-03-17 20:55:59 -03:00
Douglas Barbosa Alexandre a2bbf00477 Refactor spam filtering on issues API 2016-02-02 11:25:44 -02:00
Stan Hu d20e75a8d8 Support Akismet spam checking for creation of issues via API
Currently any spam detected by Akismet by non-members via API will be logged
in a separate table in the admin page.

Closes #5612
2016-02-02 11:25:44 -02:00
Dmitriy Zaporozhets 9f166a8649 Merge branch 'rename-abilities' into 'master'
Rename abilities to correspond contoller/model action names

write_ was renamed to create_
modify_  was renamed to update_

So now in update action we have next code

```
def create
  can?(current_user, :create_issue, @issue)
end

def update
  can?(current_user, :update_issue, @issue)
end
```

See merge request !896
2015-06-26 16:39:17 +00:00
Dmitriy Zaporozhets 58ceb8e950
Only people who can manage issue can assign labels to it
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-26 16:02:57 +02:00
Dmitriy Zaporozhets 342d553709
Rename abilities to correspond contoller/model action names
write_ was renamed to create_
modify_  was renamed to update_

So now in update action we have next code

def create
  can?(current_user, :create_issue, @issue)
end

def update
  can?(current_user, :update_issue, @issue)
end

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-26 15:55:56 +02:00
jubianchi 2c544d43c8 Query issues, merge requests and milestones with their IID through API 2015-05-02 10:44:52 +02:00
Dmitriy Zaporozhets bdfb349ff7 Refactor and improve sorting objects in API for projects, issues and merge requests 2015-02-05 22:00:54 -08:00
Dmitriy Zaporozhets 62ed1c537e Explicitly define ordering in models using default_scope 2015-02-05 14:20:55 -08:00
jubianchi f258a59ef6 Filters issues by milestone via API 2014-09-26 22:03:37 +02:00
jubianchi 998cd3cb63 Improve error reporting on users API
* users (#6878, #3526, #4209): Validation error messages are now exposed through 400 responses, 409 response are sent in case of duplicate email or username
* MRs (#5335): 409 responses are sent in case of duplicate merge request (source/target branches), 422 responses are sent when submiting MR fo/from unrelated forks
* issues
* labels
* projects
2014-09-16 01:25:24 +02:00
Dmitriy Zaporozhets 66516da3c1
Explicit issues order in API. Fixes tests for mysql. Again :)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-04 17:15:08 +03:00
jubianchi 0ac4a933ff Filters issues by labels via API 2014-09-04 14:41:31 +02:00
Dmitriy Zaporozhets 93f15a4953
Explicit order of issues in API. Fixes specs for mysql db
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-03 22:57:32 +03:00
Dmitriy Zaporozhets 20c2e90222
Refactor finders. Prevent circular dependency error
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-02 15:28:27 +03:00