Skip to content

Add RateLimiter to RawController

Mayra Cabrera requested to merge 48717-rate-limit-raw-controller-show into master

What does this MR do?

Add a Rate Limiter Request to RawController.

  • Limits raw requests to 300 per minute and per raw path.
  • Add a new attribute to ApplicationSettings so user can change this value on their instance.
  • Uses Gitlab::ActionRateLimiter to limit the raw requests.
  • Add a new method into ActionRateLimiter to log the event into auth.log

Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/48717

Does this MR meet the acceptance criteria?

Conformity

Performance and testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team

Screenshots

Admin area Raw endpoint blocked
Screen_Shot_2019-07-22_at_9.07.10_AM Screen_Shot_2019-07-16_at_9.12.46_AM

Manual QA:

  1. For testing purposes, the rate limit request was set to 10 requests per minute.
  2. First tab uses: http://localhost:3000/root/gitlab-ce/raw/9c2d0d87581f34567e33de1b384f1f360edcd4b7/app/helpers/labels_helper.rb
  3. Second tab uses: http://localhost:3000/root/gitlab-ce/raw/9C2D0D87581f34567e33de1b384f1f360eDcd4b7/app/helpers/labels_helper.rb

20190717

To do

  • Make RateLimiter to accept a string as a key (Right now it only accepts Active Record models)
  • Limit endpoint to 300 requests per minute
    • Value should be read from ApplicationSetting or config. Default to 300.
  • If there are more log the requests (probably to auth.log)
  • Tests and refactor
  • Manual QA
Edited by Mayra Cabrera

Merge request reports