Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-06-14 03:08:16 +00:00
parent 30da0e79d2
commit ef9eff8e7e
22 changed files with 171 additions and 64 deletions

View File

@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-git-lfs-limits-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
%h5

View File

@ -1,5 +1,5 @@
= form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-import-export-limits-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
= html_escape(_("Set any rate limit to %{code_open}0%{code_close} to disable the limit.")) % { code_open: '<code>'.html_safe, code_close: '</code>'.html_safe }

View File

@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-ip-limits-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
= _("Rate limits can help reduce request volume (like from crawlers or abusive bots).")

View File

@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-issue-limits-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group

View File

@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: network_admin_application_settings_path(anchor: anchor), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
= _("Rate limits can help reduce request volume (like from crawlers or abusive bots).")

View File

@ -1,5 +1,5 @@
= form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-note-limits-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group

View File

@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-outbound-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group

View File

@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-performance-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group

View File

@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-pipeline-limits-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group

View File

@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-protected-paths-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group

View File

@ -1,5 +1,5 @@
= form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-search-limits-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group

View File

@ -1,5 +1,5 @@
= form_for @application_setting, url: network_admin_application_settings_path(anchor: 'js-users-api-limits-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
= form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group

View File

@ -1,3 +1,6 @@
- add_to_breadcrumbs _('Runners'), group_runners_path(@group)
= render 'shared/runners/runner_details', runner: @runner
- if Feature.enabled?(:group_runner_view_ui)
#js-group-runner-show{ data: {runner_id: @runner.id, runners_path: group_runners_path(@group)} }
- else
= render 'shared/runners/runner_details', runner: @runner

View File

@ -0,0 +1,8 @@
---
name: group_runner_view_ui
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/89638/
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/364811
milestone: '15.1'
type: development
group: group::runner
default_enabled: false

View File

@ -15,7 +15,7 @@ class RemoveInvalidIntegrations < Gitlab::Database::Migration[2.0]
end
# Isolated version of the Integration model
class Integration < ApplicationRecord
class Integration < MigrationRecord
self.table_name = 'integrations'
self.inheritance_column = :_type_disabled
end

View File

@ -127,6 +127,7 @@ There are several ways you can authenticate with the GitLab API:
- [OAuth2 tokens](#oauth2-tokens)
- [Personal access tokens](../user/profile/personal_access_tokens.md)
- [Project access tokens](../user/project/settings/project_access_tokens.md)
- [Group access tokens](../user/group/settings/group_access_tokens.md)
- [Session cookie](#session-cookie)
- [GitLab CI/CD job token](../ci/jobs/ci_job_token.md) **(Specific endpoints only)**

View File

@ -33,10 +33,10 @@ module Gitlab
l.strip.empty? || (!allow_only_quotes && l.start_with?('>'))
end
encoded_body = body.force_encoding(encoding).encode("UTF-8")
encoded_body = force_utf8(body.force_encoding(encoding))
return encoded_body unless @append_reply
[encoded_body, stripped_text.force_encoding(encoding).encode("UTF-8")]
[encoded_body, force_utf8(stripped_text.force_encoding(encoding))]
end
private
@ -70,13 +70,29 @@ module Gitlab
return if object.nil?
if object.charset
object.body.decoded.force_encoding(object.charset.gsub(/utf8/i, "UTF-8")).encode("UTF-8").to_s
# A part of a multi-part may have a different encoding. Its encoding
# is denoted in its header. For example:
#
# ```
# ------=_Part_2192_32400445.1115745999735
# Content-Type: text/plain; charset=ISO-8859-1
# Content-Transfer-Encoding: 7bit
#
# Plain email.
# ```
# So, we had to force its part to corresponding encoding before able
# to convert it to UTF-8
force_utf8(object.body.decoded.force_encoding(object.charset.gsub(/utf8/i, "UTF-8")))
else
object.body.to_s
end
rescue StandardError
nil
end
def force_utf8(str)
Gitlab::EncodingHelper.encode_utf8(str).to_s
end
end
end
end

View File

@ -11,7 +11,7 @@ module RuboCop
ENFORCED_SINCE = 2022_04_26_00_00_00
MSG = <<~MSG
Don't inherit from ActiveRecord::Base but use MigrationRecord instead.
Don't inherit from ActiveRecord::Base or ApplicationRecord but use MigrationRecord instead.
See https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html#example-usage-of-activerecord-classes.
MSG
@ -19,9 +19,13 @@ module RuboCop
(class _ (const (const _ :ActiveRecord) :Base) _)
PATTERN
def_node_search :inherits_from_application_record?, <<~PATTERN
(class _ (const _ :ApplicationRecord) _)
PATTERN
def on_class(node)
return unless relevant_migration?(node)
return unless inherits_from_active_record_base?(node)
return unless inherits_from_active_record_base?(node) || inherits_from_application_record?(node)
add_offense(node, location: :expression)
end

View File

@ -149,31 +149,37 @@ RSpec.describe "Group Runners" do
create(:ci_runner, :group, groups: [group], description: 'runner-foo', contacted_at: Time.zone.now)
end
it 'user edits the runner to be protected' do
visit edit_group_runner_path(group, runner)
expect(page.find_field('runner[access_level]')).not_to be_checked
check 'runner_access_level'
click_button 'Save changes'
expect(page).to have_content 'Protected Yes'
end
context 'when a runner has a tag' do
context 'when group_runner_view_ui is disabled' do
before do
runner.update!(tag_list: ['tag'])
stub_feature_flags(group_runner_view_ui: false)
end
it 'user edits runner not to run untagged jobs' do
it 'user edits the runner to be protected' do
visit edit_group_runner_path(group, runner)
expect(page.find_field('runner[run_untagged]')).to be_checked
expect(page.find_field('runner[access_level]')).not_to be_checked
uncheck 'runner_run_untagged'
check 'runner_access_level'
click_button 'Save changes'
expect(page).to have_content 'Can run untagged jobs No'
expect(page).to have_content 'Protected Yes'
end
context 'when a runner has a tag' do
before do
runner.update!(tag_list: ['tag'])
end
it 'user edits runner not to run untagged jobs' do
visit edit_group_runner_path(group, runner)
expect(page.find_field('runner[run_untagged]')).to be_checked
uncheck 'runner_run_untagged'
click_button 'Save changes'
expect(page).to have_content 'Can run untagged jobs No'
end
end
end
end

View File

@ -11,7 +11,7 @@ In-Reply-To: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
Subject: The message subject! @all
Mime-Version: 1.0
Content-Type: text/plain;
charset=ISO-8859-1
charset=Shift_JIS
Content-Transfer-Encoding: 7bit
X-Sieve: CMU Sieve 2.2
X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,

View File

@ -268,5 +268,72 @@ RSpec.describe Gitlab::Email::ReplyParser do
expect(test_parse_body(fixture_file("emails/valid_new_issue_with_quote.eml"), { append_reply: true }))
.to contain_exactly(body, reply)
end
context 'non-UTF-8 content' do
let(:charset) { '; charset=Shift_JIS' }
let(:raw_content) do
<<-BODY.strip_heredoc.chomp
From: Jake the Dog <alan@adventuretime.ooo>
To: incoming+email-test-project_id-issue-@appmail.adventuretime.ooo
Message-ID: <CAH_Wr+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
Subject: The message subject! @all
Content-Type: text/plain#{charset}
Content-Transfer-Encoding: 8bit
BODY
end
# Strip encoding to simulate the case when Ruby fallback to ASCII-8bit
# when it meets an unknown encoding
let(:encoded_content) { raw_content.encode("Shift_JIS").bytes.pack("c*") }
it "parses body under UTF-8 encoding" do
expect(test_parse_body(encoded_content))
.to eq(<<-BODY.strip_heredoc.chomp)
BODY
end
# This test would raise an exception if encoding is not handled properly
# Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/364329
context 'charset is absent and reply trimming is disabled' do
let(:charset) { '' }
it "parses body under UTF-8 encoding" do
expect(test_parse_body(encoded_content, { trim_reply: false }))
.to eq(<<-BODY.strip_heredoc.chomp)
BODY
end
end
context 'multipart email' do
let(:raw_content) do
<<-BODY.strip_heredoc.chomp
From: Jake the Dog <alan@adventuretime.ooo>
To: incoming+email-test-project_id-issue-@appmail.adventuretime.ooo
Message-ID: <CAH_Wr+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
Subject: The message subject! @all
Content-Type: multipart/alternative;
boundary=Apple-Mail-B41C7F8E-3639-49B0-A5D5-440E125A7105
Content-Transfer-Encoding: 7bbit
--Apple-Mail-B41C7F8E-3639-49B0-A5D5-440E125A7105
Content-Type: text/plain
Content-Transfer-Encodng: 7bit
BODY
end
it "parses body under UTF-8 encoding" do
expect(test_parse_body(encoded_content, { trim_reply: false }))
.to eq(<<-BODY.strip_heredoc.chomp)
BODY
end
end
end
end
end

View File

@ -6,53 +6,55 @@ require_relative '../../../../rubocop/cop/migration/migration_record'
RSpec.describe RuboCop::Cop::Migration::MigrationRecord do
subject(:cop) { described_class.new }
shared_examples 'a disabled cop' do
shared_examples 'a disabled cop' do |klass|
it 'does not register any offenses' do
expect_no_offenses(<<~SOURCE)
class MyMigration < Gitlab::Database::Migration[2.0]
class Project < ActiveRecord::Base
class Project < #{klass}
end
end
SOURCE
end
end
context 'outside of a migration' do
it_behaves_like 'a disabled cop'
end
context 'in migration' do
before do
allow(cop).to receive(:in_migration?).and_return(true)
%w(ActiveRecord::Base ApplicationRecord).each do |klass|
context 'outside of a migration' do
it_behaves_like 'a disabled cop', klass
end
context 'in an old migration' do
context 'in migration' do
before do
allow(cop).to receive(:version).and_return(described_class::ENFORCED_SINCE - 5)
allow(cop).to receive(:in_migration?).and_return(true)
end
it_behaves_like 'a disabled cop'
end
context 'in an old migration' do
before do
allow(cop).to receive(:version).and_return(described_class::ENFORCED_SINCE - 5)
end
context 'that is recent' do
before do
allow(cop).to receive(:version).and_return(described_class::ENFORCED_SINCE)
it_behaves_like 'a disabled cop', klass
end
it 'adds an offense if inheriting from ActiveRecord::Base' do
expect_offense(<<~RUBY)
class Project < ActiveRecord::Base
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't inherit from ActiveRecord::Base but use MigrationRecord instead.[...]
context 'that is recent' do
before do
allow(cop).to receive(:version).and_return(described_class::ENFORCED_SINCE)
end
it "adds an offense if inheriting from #{klass}" do
expect_offense(<<~RUBY)
class Project < #{klass}
^^^^^^^^^^^^^^^^#{'^' * klass.length} Don't inherit from ActiveRecord::Base or ApplicationRecord but use MigrationRecord instead.[...]
end
RUBY
end
RUBY
end
it 'adds an offense if inheriting from ::ActiveRecord::Base' do
expect_offense(<<~RUBY)
class Project < ::ActiveRecord::Base
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't inherit from ActiveRecord::Base but use MigrationRecord instead.[...]
it "adds an offense if inheriting from ::#{klass}" do
expect_offense(<<~RUBY)
class Project < ::#{klass}
^^^^^^^^^^^^^^^^^^#{'^' * klass.length} Don't inherit from ActiveRecord::Base or ApplicationRecord but use MigrationRecord instead.[...]
end
RUBY
RUBY
end
end
end
end