Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8fc6799a
Commit
8fc6799a
authored
Nov 05, 2021
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace dotenv constants with application limits
Changelog: other
parent
94f56232
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
9 deletions
+51
-9
app/services/ci/parse_dotenv_artifact_service.rb
app/services/ci/parse_dotenv_artifact_service.rb
+13
-6
doc/administration/instance_limits.md
doc/administration/instance_limits.md
+34
-0
doc/user/gitlab_com/index.md
doc/user/gitlab_com/index.md
+1
-0
spec/services/ci/parse_dotenv_artifact_service_spec.rb
spec/services/ci/parse_dotenv_artifact_service_spec.rb
+3
-3
No files found.
app/services/ci/parse_dotenv_artifact_service.rb
View file @
8fc6799a
...
...
@@ -2,8 +2,7 @@
module
Ci
class
ParseDotenvArtifactService
<
::
BaseService
MAX_ACCEPTABLE_DOTENV_SIZE
=
5
.
kilobytes
MAX_ACCEPTABLE_VARIABLES_COUNT
=
20
include
::
Gitlab
::
Utils
::
StrongMemoize
SizeLimitError
=
Class
.
new
(
StandardError
)
ParserError
=
Class
.
new
(
StandardError
)
...
...
@@ -27,9 +26,9 @@ module Ci
raise
ArgumentError
,
'Artifact is not dotenv file type'
end
unless
artifact
.
file
.
size
<
MAX_ACCEPTABLE_DOTENV_SIZE
unless
artifact
.
file
.
size
<
dotenv_size_limit
raise
SizeLimitError
,
"Dotenv Artifact Too Big. Maximum Allowable Size:
#{
MAX_ACCEPTABLE_DOTENV_SIZE
}
"
"Dotenv Artifact Too Big. Maximum Allowable Size:
#{
dotenv_size_limit
}
"
end
end
...
...
@@ -45,9 +44,9 @@ module Ci
end
end
if
variables
.
size
>
MAX_ACCEPTABLE_VARIABLES_COUNT
if
variables
.
size
>
dotenv_variable_limit
raise
SizeLimitError
,
"Dotenv files cannot have more than
#{
MAX_ACCEPTABLE_VARIABLES_COUNT
}
variables"
"Dotenv files cannot have more than
#{
dotenv_variable_limit
}
variables"
end
variables
...
...
@@ -60,5 +59,13 @@ module Ci
result
.
each
(
&
:strip!
)
end
def
dotenv_variable_limit
strong_memoize
(
:dotenv_variable_limit
)
{
project
.
actual_limits
.
dotenv_variables
}
end
def
dotenv_size_limit
strong_memoize
(
:dotenv_size_limit
)
{
project
.
actual_limits
.
dotenv_size
}
end
end
end
doc/administration/instance_limits.md
View file @
8fc6799a
...
...
@@ -605,6 +605,40 @@ To disable this limitation entirely, disable the feature flag in the console:
Feature
.
disable
(
:ci_yaml_limit_size
)
```
### Limit dotenv variables
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/321552) in GitLab 14.5.
You can set a limit on the maximum number of variables inside of a dotenv artifact.
This limit is checked every time a dotenv file is exported as an artifact.
Set the limit to
`0`
to disable it. Defaults to
`0`
on self-managed instances.
To set this limit to
`100`
on a self-managed instance, run the following command in the
[
GitLab Rails console
](
operations/rails_console.md#starting-a-rails-console-session
)
:
```
ruby
Plan
.
default
.
actual_limits
.
update!
(
dotenv_variable_limit:
100
)
```
This limit is
[
enabled on GitLab.com
](
../user/gitlab_com/index.md#gitlab-cicd
)
.
### Limit dotenv file size
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/321552) in GitLab 14.5.
You can set a limit on the maximum size of a dotenv artifact. This limit is checked
every time a dotenv file is exported as an artifact.
Set the limit to
`0`
to disable it. Defaults to 5KB.
To set this limit to 5KB on a self-managed installation, run the following in the
[
GitLab Rails console
](
operations/rails_console.md#starting-a-rails-console-session
)
:
```
ruby
Plan
.
default
.
actual_limits
.
update!
(
dotenv_size_limit:
5
.
kilobytes
)
```
## Instance monitoring and metrics
### Limit inbound incident management alerts
...
...
doc/user/gitlab_com/index.md
View file @
8fc6799a
...
...
@@ -140,6 +140,7 @@ the related documentation.
|
[
Scheduled Job Archival
](
../../user/admin_area/settings/continuous_integration.md#archive-jobs
)
| 3 months | Never |
| Max test cases per
[
unit test report
](
../../ci/unit_test_reports.md
)
|
`500_000`
| Unlimited |
|
[
Max registered runners
](
../../administration/instance_limits.md#number-of-registered-runners-per-scope
)
| Free tier:
`50`
per-group /
`50`
per-project
<br/>
All paid tiers:
`1_000`
per-group /
`1_000`
per-project |
`1_000`
per-group /
`1_000`
per-project |
|
[
Limit dotenv variables
](
../../administration/instance_limits.md#limit-dotenv-variables
)
| Free tier:
`50`
/ Premium tier:
`100`
/ Ultimate tier:
`150`
| Unlimited |
## Account and limit settings
...
...
spec/services/ci/parse_dotenv_artifact_service_spec.rb
View file @
8fc6799a
...
...
@@ -45,7 +45,7 @@ RSpec.describe Ci::ParseDotenvArtifactService do
it
'returns error'
do
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:message
]).
to
eq
(
"Dotenv Artifact Too Big. Maximum Allowable Size:
#{
described_class
::
MAX_ACCEPTABLE_DOTENV_SIZE
}
"
)
expect
(
subject
[
:message
]).
to
eq
(
"Dotenv Artifact Too Big. Maximum Allowable Size:
#{
service
.
send
(
:dotenv_size_limit
)
}
"
)
expect
(
subject
[
:http_status
]).
to
eq
(
:bad_request
)
end
end
...
...
@@ -186,7 +186,7 @@ RSpec.describe Ci::ParseDotenvArtifactService do
context
'when more than limitated variables are specified in dotenv'
do
let
(
:blob
)
do
StringIO
.
new
.
tap
do
|
s
|
(
described_class
::
MAX_ACCEPTABLE_VARIABLES_COUNT
+
1
).
times
do
|
i
|
(
service
.
send
(
:dotenv_variable_limit
)
+
1
).
times
do
|
i
|
s
<<
"KEY
#{
i
}
=VAR
#{
i
}
\n
"
end
end
.
string
...
...
@@ -194,7 +194,7 @@ RSpec.describe Ci::ParseDotenvArtifactService do
it
'returns error'
do
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:message
]).
to
eq
(
"Dotenv files cannot have more than
#{
described_class
::
MAX_ACCEPTABLE_VARIABLES_COUNT
}
variables"
)
expect
(
subject
[
:message
]).
to
eq
(
"Dotenv files cannot have more than
#{
service
.
send
(
:dotenv_variable_limit
)
}
variables"
)
expect
(
subject
[
:http_status
]).
to
eq
(
:bad_request
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment