Commit c9192d5c authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents b94d2478 707d01f5
...@@ -2499,7 +2499,6 @@ Database/MultipleDatabases: ...@@ -2499,7 +2499,6 @@ Database/MultipleDatabases:
- 'ee/spec/services/ee/merge_requests/update_service_spec.rb' - 'ee/spec/services/ee/merge_requests/update_service_spec.rb'
- 'lib/backup/database.rb' - 'lib/backup/database.rb'
- 'lib/after_commit_queue.rb' - 'lib/after_commit_queue.rb'
- 'lib/api/rubygem_packages.rb'
- 'lib/backup/manager.rb' - 'lib/backup/manager.rb'
- 'lib/gitlab/current_settings.rb' - 'lib/gitlab/current_settings.rb'
- 'lib/gitlab/database/load_balancing/load_balancer.rb' - 'lib/gitlab/database/load_balancing/load_balancer.rb'
...@@ -2535,29 +2534,20 @@ Database/MultipleDatabases: ...@@ -2535,29 +2534,20 @@ Database/MultipleDatabases:
- 'lib/gitlab/sherlock/query.rb' - 'lib/gitlab/sherlock/query.rb'
- 'lib/system_check/orphans/repository_check.rb' - 'lib/system_check/orphans/repository_check.rb'
- 'spec/db/schema_spec.rb' - 'spec/db/schema_spec.rb'
- 'spec/features/admin/dashboard_spec.rb'
- 'spec/initializers/database_config_spec.rb' - 'spec/initializers/database_config_spec.rb'
- 'spec/initializers/lograge_spec.rb'
- 'spec/lib/backup/manager_spec.rb' - 'spec/lib/backup/manager_spec.rb'
- 'spec/lib/gitlab/current_settings_spec.rb' - 'spec/lib/gitlab/current_settings_spec.rb'
- 'spec/lib/gitlab/database_spec.rb' - 'spec/lib/gitlab/database_spec.rb'
- 'spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb'
- 'spec/lib/gitlab/import_export/project/tree_saver_spec.rb'
- 'spec/lib/gitlab/metrics/subscribers/active_record_spec.rb' - 'spec/lib/gitlab/metrics/subscribers/active_record_spec.rb'
- 'spec/lib/gitlab/pagination/keyset/order_spec.rb'
- 'spec/lib/gitlab/profiler_spec.rb' - 'spec/lib/gitlab/profiler_spec.rb'
- 'spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb'
- 'spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb'
- 'spec/lib/gitlab/usage_data_metrics_spec.rb' - 'spec/lib/gitlab/usage_data_metrics_spec.rb'
- 'spec/lib/gitlab/usage_data_queries_spec.rb' - 'spec/lib/gitlab/usage_data_queries_spec.rb'
- 'spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb' - 'spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb'
- 'spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/joins_spec.rb' - 'spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/joins_spec.rb'
- 'spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb' - 'spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb'
- 'spec/lib/gitlab/utils/usage_data_spec.rb' - 'spec/lib/gitlab/utils/usage_data_spec.rb'
- 'spec/models/application_setting_spec.rb'
- 'spec/models/project_feature_usage_spec.rb' - 'spec/models/project_feature_usage_spec.rb'
- 'spec/models/users_statistics_spec.rb' - 'spec/models/users_statistics_spec.rb'
- 'spec/requests/api/statistics_spec.rb'
- 'spec/services/users/activity_service_spec.rb' - 'spec/services/users/activity_service_spec.rb'
- 'spec/support/caching.rb' - 'spec/support/caching.rb'
- 'spec/support/gitlab/usage/metrics_instrumentation_shared_examples.rb' - 'spec/support/gitlab/usage/metrics_instrumentation_shared_examples.rb'
...@@ -2569,5 +2559,3 @@ Database/MultipleDatabases: ...@@ -2569,5 +2559,3 @@ Database/MultipleDatabases:
- 'spec/support/helpers/usage_data_helpers.rb' - 'spec/support/helpers/usage_data_helpers.rb'
- 'spec/tasks/gitlab/backup_rake_spec.rb' - 'spec/tasks/gitlab/backup_rake_spec.rb'
- 'spec/tasks/gitlab/db_rake_spec.rb' - 'spec/tasks/gitlab/db_rake_spec.rb'
- 'spec/workers/analytics/usage_trends/counter_job_worker_spec.rb'
- 'spec/workers/users/create_statistics_worker_spec.rb'
...@@ -10,9 +10,9 @@ module Security ...@@ -10,9 +10,9 @@ module Security
end end
def execute def execute
store_reports
mark_project_as_vulnerable!
set_latest_pipeline! set_latest_pipeline!
mark_project_as_vulnerable!
store_reports
errors.any? ? error(full_errors) : success errors.any? ? error(full_errors) : success
end end
......
...@@ -19,7 +19,7 @@ module Gitlab ...@@ -19,7 +19,7 @@ module Gitlab
end end
def hash def hash
name.hash ^ severity.hash name.hash ^ severity.hash ^ id.hash ^ url.hash
end end
def to_hash def to_hash
......
...@@ -135,7 +135,8 @@ RSpec.describe Gitlab::Ci::Reports::DependencyList::Report do ...@@ -135,7 +135,8 @@ RSpec.describe Gitlab::Ci::Reports::DependencyList::Report do
it 'does not duplicate same vulnerability for dependency' do it 'does not duplicate same vulnerability for dependency' do
vulnerabilities = [{ name: 'problem', severity: 'high', id: 2, url: 'some_url_2' }, vulnerabilities = [{ name: 'problem', severity: 'high', id: 2, url: 'some_url_2' },
{ name: 'problem2', severity: 'medium', id: 4, url: 'some_url_4' }] { name: 'problem2', severity: 'medium', id: 4, url: 'some_url_4' },
{ name: 'problem3', severity: 'medium', id: nil, url: nil }]
dependency[:vulnerabilities] = [vulnerabilities.first] dependency[:vulnerabilities] = [vulnerabilities.first]
with_extra_vuln_from_another_report = dependency.dup.merge(vulnerabilities: vulnerabilities) with_extra_vuln_from_another_report = dependency.dup.merge(vulnerabilities: vulnerabilities)
......
...@@ -41,6 +41,26 @@ RSpec.describe Security::StoreReportsService do ...@@ -41,6 +41,26 @@ RSpec.describe Security::StoreReportsService do
expect { execute_service_object }.to change { project.reload.vulnerability_statistic&.latest_pipeline_id }.from(nil).to(pipeline.id) expect { execute_service_object }.to change { project.reload.vulnerability_statistic&.latest_pipeline_id }.from(nil).to(pipeline.id)
end end
context 'when the StoreReportService raises an error' do
let(:error) { RuntimeError.new('foo') }
before do
allow_next_instance_of(Security::StoreReportService) do |service_object|
allow(service_object).to receive(:execute).and_raise(error)
end
end
it 'marks the project as vulnerable' do
expect { execute_service_object }.to raise_error(error)
.and change { project.reload.project_setting.has_vulnerabilities }.from(false).to(true)
end
it 'updates the `latest_pipeline_id` attribute of the associated `vulnerability_statistic` record' do
expect { execute_service_object }.to raise_error(error)
.and change { project.reload.vulnerability_statistic&.latest_pipeline_id }.from(nil).to(pipeline.id)
end
end
context 'when StoreReportService returns an error for a report' do context 'when StoreReportService returns an error for a report' do
let(:reports) { Gitlab::Ci::Reports::Security::Reports.new(pipeline) } let(:reports) { Gitlab::Ci::Reports::Security::Reports.new(pipeline) }
let(:sast_report) { reports.get_report('sast', sast_artifact) } let(:sast_report) { reports.get_report('sast', sast_artifact) }
......
...@@ -101,7 +101,7 @@ module API ...@@ -101,7 +101,7 @@ module API
package_file = nil package_file = nil
ActiveRecord::Base.transaction do ApplicationRecord.transaction do
package = ::Packages::CreateTemporaryPackageService.new( package = ::Packages::CreateTemporaryPackageService.new(
user_project, current_user, declared_params.merge(build: current_authenticated_job) user_project, current_user, declared_params.merge(build: current_authenticated_job)
).execute(:rubygems, name: ::Packages::Rubygems::TEMPORARY_PACKAGE_NAME) ).execute(:rubygems, name: ::Packages::Rubygems::TEMPORARY_PACKAGE_NAME)
......
...@@ -2,9 +2,7 @@ include: ...@@ -2,9 +2,7 @@ include:
template: License-Scanning.gitlab-ci.yml template: License-Scanning.gitlab-ci.yml
license_scanning: license_scanning:
tags: tags: [secure_license]
- qa
- test
script: script:
- echo "Skipped" - echo "Skipped"
artifacts: artifacts:
......
...@@ -6,9 +6,7 @@ include: ...@@ -6,9 +6,7 @@ include:
template: License-Scanning.gitlab-ci.yml template: License-Scanning.gitlab-ci.yml
dependency_scanning: dependency_scanning:
tags: tags: [secure_report]
- qa
- test
script: script:
- echo "Skipped" - echo "Skipped"
artifacts: artifacts:
...@@ -16,9 +14,7 @@ dependency_scanning: ...@@ -16,9 +14,7 @@ dependency_scanning:
dependency_scanning: gl-dependency-scanning-report.json dependency_scanning: gl-dependency-scanning-report.json
container_scanning: container_scanning:
tags: tags: [secure_report]
- qa
- test
only: null # Template defaults to feature branches only only: null # Template defaults to feature branches only
variables: variables:
GIT_STRATEGY: fetch # Template defaults to none, which stops fetching the premade report GIT_STRATEGY: fetch # Template defaults to none, which stops fetching the premade report
...@@ -29,9 +25,7 @@ container_scanning: ...@@ -29,9 +25,7 @@ container_scanning:
container_scanning: gl-container-scanning-report.json container_scanning: gl-container-scanning-report.json
sast: sast:
tags: tags: [secure_report]
- qa
- test
only: null # Template defaults to feature branches only only: null # Template defaults to feature branches only
script: script:
- echo "Skipped" - echo "Skipped"
...@@ -40,9 +34,7 @@ sast: ...@@ -40,9 +34,7 @@ sast:
sast: gl-sast-report.json sast: gl-sast-report.json
dast: dast:
tags: tags: [secure_report]
- qa
- test
only: null # Template defaults to feature branches only only: null # Template defaults to feature branches only
script: script:
- echo "Skipped" - echo "Skipped"
...@@ -51,9 +43,7 @@ dast: ...@@ -51,9 +43,7 @@ dast:
dast: gl-dast-report.json dast: gl-dast-report.json
license_scanning: license_scanning:
tags: tags: [secure_report]
- qa
- test
script: script:
- echo "Skipped" - echo "Skipped"
artifacts: artifacts:
......
...@@ -2,9 +2,7 @@ include: ...@@ -2,9 +2,7 @@ include:
template: License-Scanning.gitlab-ci.yml template: License-Scanning.gitlab-ci.yml
.sast-analyzer: .sast-analyzer:
tags: tags: [secure_sast]
- qa
- test
script: script:
- echo "Skipped" - echo "Skipped"
artifacts: artifacts:
...@@ -12,9 +10,7 @@ include: ...@@ -12,9 +10,7 @@ include:
sast: gl-sast-report.json sast: gl-sast-report.json
license_scanning: license_scanning:
tags: tags: [secure_sast]
- qa
- test
script: script:
- echo "Skipped" - echo "Skipped"
artifacts: artifacts:
......
...@@ -30,7 +30,7 @@ module QA ...@@ -30,7 +30,7 @@ module QA
@runner = Resource::Runner.fabricate! do |runner| @runner = Resource::Runner.fabricate! do |runner|
runner.project = @project runner.project = @project
runner.name = @executor runner.name = @executor
runner.tags = %w[qa test] runner.tags = ['secure_report']
end end
# Push fixture to generate Secure reports # Push fixture to generate Secure reports
......
...@@ -48,7 +48,7 @@ module QA ...@@ -48,7 +48,7 @@ module QA
Resource::Runner.fabricate! do |runner| Resource::Runner.fabricate! do |runner|
runner.project = project runner.project = project
runner.name = "runner-for-#{project.name}" runner.name = "runner-for-#{project.name}"
runner.tags = %w[qa test] runner.tags = ['secure_sast']
end end
end end
......
...@@ -17,7 +17,7 @@ module QA ...@@ -17,7 +17,7 @@ module QA
@runner = Resource::Runner.fabricate! do |runner| @runner = Resource::Runner.fabricate! do |runner|
runner.project = @project runner.project = @project
runner.name = "runner-for-#{@project.name}" runner.name = "runner-for-#{@project.name}"
runner.tags = %w[qa test] runner.tags = ['secure_license']
end end
end end
......
...@@ -24,7 +24,7 @@ module QA ...@@ -24,7 +24,7 @@ module QA
@runner = Resource::Runner.fabricate! do |runner| @runner = Resource::Runner.fabricate! do |runner|
runner.project = @project runner.project = @project
runner.name = executor runner.name = executor
runner.tags = %w[qa test] runner.tags = ['secure_license']
end end
Resource::Repository::ProjectPush.fabricate! do |project_push| Resource::Repository::ProjectPush.fabricate! do |project_push|
......
...@@ -22,7 +22,7 @@ module QA ...@@ -22,7 +22,7 @@ module QA
@runner = Resource::Runner.fabricate! do |runner| @runner = Resource::Runner.fabricate! do |runner|
runner.project = @project runner.project = @project
runner.name = @executor runner.name = @executor
runner.tags = %w[qa test] runner.tags = ['secure_report']
end end
# Push fixture to generate Secure reports # Push fixture to generate Secure reports
......
...@@ -44,7 +44,7 @@ module QA ...@@ -44,7 +44,7 @@ module QA
@runner = Resource::Runner.fabricate_via_api! do |runner| @runner = Resource::Runner.fabricate_via_api! do |runner|
runner.project = @project runner.project = @project
runner.name = "runner-for-#{@project.name}" runner.name = "runner-for-#{@project.name}"
runner.tags = %w[qa test] runner.tags = ['secure_report']
end end
# Push fixture to generate Secure reports # Push fixture to generate Secure reports
......
...@@ -30,7 +30,7 @@ module QA ...@@ -30,7 +30,7 @@ module QA
@runner = Resource::Runner.fabricate! do |runner| @runner = Resource::Runner.fabricate! do |runner|
runner.project = @project runner.project = @project
runner.name = @executor runner.name = @executor
runner.tags = %w[qa test] runner.tags = ['secure_report']
end end
@source = Resource::Repository::ProjectPush.fabricate! do |push| @source = Resource::Repository::ProjectPush.fabricate! do |push|
......
...@@ -19,8 +19,8 @@ RSpec.describe 'admin visits dashboard' do ...@@ -19,8 +19,8 @@ RSpec.describe 'admin visits dashboard' do
# Make sure the fork_networks & fork_networks reltuples have been updated # Make sure the fork_networks & fork_networks reltuples have been updated
# to get a correct count on postgresql # to get a correct count on postgresql
ActiveRecord::Base.connection.execute('ANALYZE fork_networks') ForkNetwork.connection.execute('ANALYZE fork_networks')
ActiveRecord::Base.connection.execute('ANALYZE fork_network_members') ForkNetwork.connection.execute('ANALYZE fork_network_members')
visit admin_root_path visit admin_root_path
......
...@@ -212,7 +212,7 @@ RSpec.describe 'lograge', type: :request do ...@@ -212,7 +212,7 @@ RSpec.describe 'lograge', type: :request do
end end
before do before do
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') ApplicationRecord.connection.execute('SELECT pg_sleep(0.1);')
end end
context 'when RequestStore is enabled', :request_store do context 'when RequestStore is enabled', :request_store do
......
...@@ -190,7 +190,7 @@ RSpec.describe Gitlab::ImportExport::FastHashSerializer do ...@@ -190,7 +190,7 @@ RSpec.describe Gitlab::ImportExport::FastHashSerializer do
end end
it 'does not complain about non UTF-8 characters in MR diff files' do it 'does not complain about non UTF-8 characters in MR diff files' do
ActiveRecord::Base.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'") MergeRequest.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'")
expect(subject['merge_requests'].first['merge_request_diff']).not_to be_empty expect(subject['merge_requests'].first['merge_request_diff']).not_to be_empty
end end
......
...@@ -386,7 +386,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do ...@@ -386,7 +386,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
end end
it 'does not complain about non UTF-8 characters in MR diff files' do it 'does not complain about non UTF-8 characters in MR diff files' do
ActiveRecord::Base.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'") MergeRequestDiffFile.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'")
expect(project_tree_saver.save).to be true expect(project_tree_saver.save).to be true
end end
......
...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Pagination::Keyset::Order do ...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Pagination::Keyset::Order do
let(:order) { nil } let(:order) { nil }
def run_query(query) def run_query(query)
ActiveRecord::Base.connection.execute(query).to_a ApplicationRecord.connection.execute(query).to_a
end end
def build_query(order:, where_conditions: nil, limit: nil) def build_query(order:, where_conditions: nil, limit: nil)
......
...@@ -27,7 +27,7 @@ RSpec.describe Gitlab::QueryLimiting::ActiveSupportSubscriber do ...@@ -27,7 +27,7 @@ RSpec.describe Gitlab::QueryLimiting::ActiveSupportSubscriber do
context 'when the query is actually a rails cache hit' do context 'when the query is actually a rails cache hit' do
it 'does not increment the number of executed SQL queries' do it 'does not increment the number of executed SQL queries' do
ActiveRecord::Base.connection.cache do User.connection.cache do
User.count User.count
User.count User.count
end end
......
...@@ -256,7 +256,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do ...@@ -256,7 +256,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered
call_subject(job, 'test_queue') do call_subject(job, 'test_queue') do
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') ApplicationRecord.connection.execute('SELECT pg_sleep(0.1);')
end end
end end
...@@ -267,7 +267,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do ...@@ -267,7 +267,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
expect(logger).to receive(:info).with(expected_end_payload).ordered expect(logger).to receive(:info).with(expected_end_payload).ordered
call_subject(job.dup, 'test_queue') do call_subject(job.dup, 'test_queue') do
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') ApplicationRecord.connection.execute('SELECT pg_sleep(0.1);')
end end
Gitlab::SafeRequestStore.clear! Gitlab::SafeRequestStore.clear!
...@@ -298,7 +298,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do ...@@ -298,7 +298,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true) allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true)
end end
let(:db_config_name) { ::Gitlab::Database.db_config_name(ActiveRecord::Base.connection) } let(:db_config_name) { ::Gitlab::Database.db_config_name(ApplicationRecord.connection) }
let(:expected_end_payload_with_db) do let(:expected_end_payload_with_db) do
expected_end_payload.merge( expected_end_payload.merge(
......
...@@ -927,7 +927,7 @@ RSpec.describe ApplicationSetting do ...@@ -927,7 +927,7 @@ RSpec.describe ApplicationSetting do
context 'when ApplicationSettings does not have a primary key' do context 'when ApplicationSettings does not have a primary key' do
before do before do
allow(ActiveRecord::Base.connection).to receive(:primary_key).with(described_class.table_name).and_return(nil) allow(described_class.connection).to receive(:primary_key).with(described_class.table_name).and_return(nil)
end end
it 'raises an exception' do it 'raises an exception' do
......
...@@ -63,7 +63,7 @@ RSpec.describe API::Statistics, 'Statistics' do ...@@ -63,7 +63,7 @@ RSpec.describe API::Statistics, 'Statistics' do
# Make sure the reltuples have been updated # Make sure the reltuples have been updated
# to get a correct count on postgresql # to get a correct count on postgresql
tables_to_analyze.each do |table| tables_to_analyze.each do |table|
ActiveRecord::Base.connection.execute("ANALYZE #{table}") ApplicationRecord.connection.execute("ANALYZE #{table}")
end end
get api(path, admin) get api(path, admin)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment