Add RateLimiter to RawController
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
-
Changelog entry - [-] Documentation created/updated or follow-up review issue created
- [-] Code review guidelines
- [-] Merge request performance guidelines
-
Style guides -
Database guides -
Separation of EE specific content
Performance and testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
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 |
---|---|
Manual QA:
- For testing purposes, the rate limit request was set to
10
requests per minute. - First tab uses:
http://localhost:3000/root/gitlab-ce/raw/9c2d0d87581f34567e33de1b384f1f360edcd4b7/app/helpers/labels_helper.rb
- Second tab uses:
http://localhost:3000/root/gitlab-ce/raw/9C2D0D87581f34567e33de1b384f1f360eDcd4b7/app/helpers/labels_helper.rb
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