Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-11-11 03:10:33 +00:00
parent 5eba9c0d33
commit fecccb42ab
15 changed files with 97 additions and 44 deletions

View File

@ -126,13 +126,9 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated
def transformed_blob_data
@transformed_blob ||= if blob.path.ends_with?('.ipynb')
new_blob = IpynbDiff.transform(blob.data,
raise_errors: true,
options: { include_metadata: false, cell_decorator: :percent })
Gitlab::AppLogger.info(new_blob ? 'IPYNBDIFF_BLOB_GENERATED' : 'IPYNBDIFF_BLOB_NIL')
new_blob
IpynbDiff.transform(blob.data,
raise_errors: true,
options: { include_metadata: false, cell_decorator: :percent })
end
@transformed_blob ||= blob.data

View File

@ -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

View File

@ -19,9 +19,7 @@
This area supports markdown. Delete this entire comment and replace it with your markdown content.
Make sure to run `bin/rake gitlab:docs:compile_deprecations` locally before committing and pushing your changes.
When ready, assign to your tech writer to review and merge.
When ready, assign to your tech writer for review. When ready, they will run `bin/rake gitlab:docs:compile_deprecations` to update the deprecations doc, then merge.
END OF BODY COMMENT -->
# The following items are not published on the docs page, but may be used in the future.

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
class CreateDotenvApplicationLimits < Gitlab::Database::Migration[1.0]
def change
add_column(:plan_limits, :dotenv_variables, :integer, default: 20, null: false)
add_column(:plan_limits, :dotenv_size, :integer, default: 5.kilobytes, null: false)
end
end

View File

@ -0,0 +1,27 @@
# frozen_string_literal: true
class InsertDotenvApplicationLimits < Gitlab::Database::Migration[1.0]
def up
create_or_update_plan_limit('dotenv_variables', 'default', 150)
create_or_update_plan_limit('dotenv_variables', 'free', 50)
create_or_update_plan_limit('dotenv_variables', 'opensource', 150)
create_or_update_plan_limit('dotenv_variables', 'premium', 100)
create_or_update_plan_limit('dotenv_variables', 'premium_trial', 100)
create_or_update_plan_limit('dotenv_variables', 'ultimate', 150)
create_or_update_plan_limit('dotenv_variables', 'ultimate_trial', 150)
create_or_update_plan_limit('dotenv_size', 'default', 5.kilobytes)
end
def down
create_or_update_plan_limit('dotenv_variables', 'default', 20)
create_or_update_plan_limit('dotenv_variables', 'free', 20)
create_or_update_plan_limit('dotenv_variables', 'opensource', 20)
create_or_update_plan_limit('dotenv_variables', 'premium', 20)
create_or_update_plan_limit('dotenv_variables', 'premium_trial', 20)
create_or_update_plan_limit('dotenv_variables', 'ultimate', 20)
create_or_update_plan_limit('dotenv_variables', 'ultimate_trial', 20)
create_or_update_plan_limit('dotenv_size', 'default', 5.kilobytes)
end
end

View File

@ -0,0 +1 @@
afb9552a4104b10b25d65a9fec478c5c28a31ec31402400554db4288033bacb6

View File

@ -0,0 +1 @@
911cc21de320d0d5716ce80ebca56433b793c2072cb62da783605c99bb9aada9

View File

@ -17574,7 +17574,9 @@ CREATE TABLE plan_limits (
ci_jobs_trace_size_limit integer DEFAULT 100 NOT NULL,
pages_file_entries integer DEFAULT 200000 NOT NULL,
dast_profile_schedules integer DEFAULT 1 NOT NULL,
external_audit_event_destinations integer DEFAULT 5 NOT NULL
external_audit_event_destinations integer DEFAULT 5 NOT NULL,
dotenv_variables integer DEFAULT 20 NOT NULL,
dotenv_size integer DEFAULT 5120 NOT NULL
);
CREATE SEQUENCE plan_limits_id_seq

View File

@ -610,6 +610,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

View File

@ -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

View File

@ -463,9 +463,7 @@ module Gitlab
diff.diff = new_diff.scan(/.*\n/)[2..-1].join('') if new_diff
Gitlab::AppLogger.info({ message: new_diff ? 'IPYNB_DIFF_GENERATED' : 'IPYNB_DIFF_NIL',
from: from&.to_s, to: to&.to_s,
lib_version: Gem.loaded_specs["ipynbdiff"].version.version })
Gitlab::AppLogger.info({ message: new_diff ? 'IPYNB_DIFF_GENERATED' : 'IPYNB_DIFF_NIL' })
rescue IpynbDiff::InvalidNotebookError => e
Gitlab::ErrorTracking.track_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/344676')

View File

@ -128,7 +128,7 @@ function run_locally_or_in_docker() {
$cmd $args
elif hash docker 2>/dev/null
then
docker run -t -v ${PWD}:/gitlab -w /gitlab --rm registry.gitlab.com/gitlab-org/gitlab-docs/lint-markdown:alpine-3.13-vale-2.10.2-markdownlint-0.26.0 ${cmd} ${args}
docker run -t -v ${PWD}:/gitlab -w /gitlab --rm registry.gitlab.com/gitlab-org/gitlab-docs/lint-markdown:alpine-3.14-vale-2.12.0-markdownlint-0.29.0 ${cmd} ${args}
else
echo
echo " ✖ ERROR: '${cmd}' not found. Install '${cmd}' or Docker to proceed." >&2

View File

@ -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

View File

@ -9,14 +9,6 @@ RSpec.configure do |config|
freeze_time { example.run }
end
config.around(:example, :time_travel) do |example|
duration = example.metadata[:time_travel]
raise 'The time_travel RSpec metadata must have an ActiveSupport::Duration value (such as `30.days`).' unless duration.is_a?(ActiveSupport::Duration)
travel(duration) { example.run }
end
config.around(:example, :time_travel_to) do |example|
date_or_time = example.metadata[:time_travel_to]

View File

@ -9,18 +9,6 @@ RSpec.describe 'time travel' do
end
end
describe ':time_travel' do
today = Date.current
it 'time-travels by the given duration', time_travel: 3.days do
expect(Date.current).to eq(today + 3.days)
end
it 'works with negative durations', time_travel: -5.days do
expect(Date.current).to eq(today - 5.days)
end
end
describe ':time_travel_to' do
it 'time-travels to the specified date', time_travel_to: '2020-01-01' do
expect(Date.current).to eq(Date.new(2020, 1, 1))