Make the DAST scanned resources limits application settings
What does this MR do and why?
Moves the DAST scanned resources and DAST configuration page limits from constants to application settings that default to 0 (disabled). This follows the convention set by other Project Bulkhead limits, and meets the requirement that the limits are off by default on Self-Managed and Dedicated.
| Setting | What it limits | GitLab.com value |
|---|---|---|
scanned_resources_csv_download_limit |
Scanned resources CSV downloads per minute per user | 5 |
scanned_resources_pipelines_query_limit |
Pipelines per minute per user whose scannedResources or scannedResourcesCount GraphQL fields are requested |
60 |
dast_configuration_show_limit |
DAST configuration page views per minute per user | 10 |
scanned_resources_artifacts_size_limit_megabytes |
Total size of the DAST and API fuzzing artifacts parsed for one pipeline, for the CSV and the GraphQL fields | 20 |
scanned_resources_artifacts_count_limit |
Number of DAST and API fuzzing artifacts parsed for one pipeline, for the CSV and the GraphQL fields | 100 |
The CSV and the GraphQL fields had their own size and count constants (MAX_DAST_ARTIFACTS_* and MAX_SCANNED_RESOURCES_ARTIFACTS_*), always with the same values. They now share one size setting and one count setting, because they protect against the same thing: parsing too many or too large reports in one request.
Why: each limit is behind a gitlab_com_derisk feature flag that's off by default. Removing the flags (!271647, !271651, !271655) would turn the limits on for Self-Managed and Dedicated on upgrade. With this MR, the limits are off everywhere until an administrator sets them, and GitLab.com sets its values through the application settings API. Raised in https://gitlab.com/gitlab-org/gitlab/-/work_items/637250#note_4254174337.
The feature flags are already enabled on GitLab.com and don't change. Once GitLab.com's settings are set to the values above, it behaves as it does today, and the flag rollouts already showed those values don't block real users.
Also moves the three rate limits from the non-configurable rate limits page to the configurable list, and rewrites the scanned resources section in instance_limits.md around the settings.
Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/637250 and https://gitlab.com/gitlab-org/gitlab/-/work_items/637251
After release
Once this is deployed to GitLab.com, the limits are off there until the settings are set, because every setting defaults to 0. The flags stay enabled.
-
Set the GitLab.com values, through a production change request run by someone with admin access:
curl --request PUT --header "PRIVATE-TOKEN: <admin_access_token>" \ --url "https://gitlab.com/api/v4/application/settings" \ --data "scanned_resources_csv_download_limit=5" \ --data "scanned_resources_pipelines_query_limit=60" \ --data "dast_configuration_show_limit=10" \ --data "scanned_resources_artifacts_size_limit_megabytes=20" \ --data "scanned_resources_artifacts_count_limit=100"Check the response includes the five values. To roll back, set any of them to
0. -
Verify the limits are enforced again. Repeat the checks from https://gitlab.com/gitlab-org/gitlab/-/work_items/637250#note_4251546495 and https://gitlab.com/gitlab-org/gitlab/-/work_items/637251#note_4251546545: the 11th DAST configuration page view in a minute and the 6th CSV download in a minute return
429, and the GraphQL fields return their errors over the limits. -
Then merge the flag removal MRs (!271647, !271651, !271655), rebased on this MR.
How to set up and validate locally
- Enable the flags:
Feature.enable(:scanned_resources_csv_limits)andFeature.enable(:dast_configuration_rate_limit). - Open a project's DAST configuration page (Secure > Security configuration > DAST) more than 10 times in a minute. It keeps loading, because the setting defaults to
0. - Set the limit:
ApplicationSetting.current.update!(dast_configuration_show_limit: 10). - Open the page more than 10 times in a minute. The 11th view returns
429.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.