feat: Add _redirects max rule count validation
What does this MR do?
Adds a new validation that limits the number rules allowed in _redirects
to 1000.
When a _redirects
file contains more than 1000 rules, the following error message is printed when the _redirects
file is requested:
The _redirects file contains (1010) rules, more than the maximum of 1000 rules. Only the first 1000 rules will be processed.
1010 rules
rule 1: valid
rule 2: valid
rule 3: valid
...
When a Pages site has more than 1000 rules, none of the rules are processed during normal requests.
Other details
We already validate that the _redirects
file isn't too large: https://gitlab.com/gitlab-org/gitlab-pages/-/blob/96458b6f5841d8df17913a60dc7dbd266ac2100b/internal/redirects/redirects.go#L116.
Depending on the average length of the rules, this file size limit still allows a very large number of rules. (I was able to
create a _redirects
file with 10000 rules that was under the current 64kb limit.)
Context
This MR came out of a discussion here: !458 (comment 655200101)
Related to #500 (closed)
Original MR !552 (closed) by @nfriend
TODO
-
I added the Changelog
trailer (e.g.Changelog: feature
) to the commits that need to be included in the changelog -
I added unit tests or they are not required -
I added acceptance tests or they are not required -
I added documentation (or it's not required) -
I followed code review guidelines -
I followed Go Style guidelines