diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 0bbfeae66563998878a62d5e44c4b3c94ef8424b..96d78034ad66fb3230fa83ad3409a1bea86b839d 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -234,6 +234,9 @@ def application_setting_params # rubocop:disable Metrics/AbcSize params[:application_setting][:valid_runner_registrars]&.delete("") params[:application_setting][:restricted_visibility_levels]&.delete("") + params[:application_setting][:package_metadata_purl_types]&.delete("") + params[:application_setting][:package_metadata_purl_types]&.map!(&:to_i) + if params[:application_setting].key?(:required_instance_ci_template) if params[:application_setting][:required_instance_ci_template].empty? params[:application_setting][:required_instance_ci_template] = nil @@ -276,6 +279,7 @@ def visible_application_setting_attributes :default_branch_name, disabled_oauth_sign_in_sources: [], import_sources: [], + package_metadata_purl_types: [], restricted_visibility_levels: [], repository_storages_weighted: {}, valid_runner_registrars: [] diff --git a/app/models/concerns/enums/package_metadata.rb b/app/models/concerns/enums/package_metadata.rb index abacee363c90424e04fd7d7de51036c7e03d2048..a866e2b995a7cebbedde5b63ebf4151fd9331439 100644 --- a/app/models/concerns/enums/package_metadata.rb +++ b/app/models/concerns/enums/package_metadata.rb @@ -20,5 +20,9 @@ class PackageMetadata def self.purl_types PURL_TYPES end + + def self.purl_types_numerical + purl_types.invert + end end end diff --git a/app/views/layouts/nav/sidebar/_admin.html.haml b/app/views/layouts/nav/sidebar/_admin.html.haml index 24b301fadce65ebef4df898a2f3204fa65d87327..2d61e40362355d904bc75267f5cd1d24413128ba 100644 --- a/app/views/layouts/nav/sidebar/_admin.html.haml +++ b/app/views/layouts/nav/sidebar/_admin.html.haml @@ -270,6 +270,7 @@ = link_to ci_cd_admin_application_settings_path, title: _('CI/CD') do %span = _('CI/CD') + = render_if_exists 'layouts/nav/ee/admin/security_and_compliance_sidebar' = nav_link(path: 'application_settings#reporting') do = link_to reporting_admin_application_settings_path, title: _('Reporting') do %span diff --git a/db/migrate/20230403145705_add_purl_sync_to_settings.rb b/db/migrate/20230403145705_add_purl_sync_to_settings.rb new file mode 100644 index 0000000000000000000000000000000000000000..3bc9ce072354879543f8065b437d314ecd4ea520 --- /dev/null +++ b/db/migrate/20230403145705_add_purl_sync_to_settings.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddPurlSyncToSettings < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :package_metadata_purl_types, :smallint, array: true, default: [] + end +end diff --git a/db/schema_migrations/20230403145705 b/db/schema_migrations/20230403145705 new file mode 100644 index 0000000000000000000000000000000000000000..80e6357e3e45d270d34d5b027e0e51f6d8c0efaf --- /dev/null +++ b/db/schema_migrations/20230403145705 @@ -0,0 +1 @@ +856d50399914b6df0c07d328723197a57806c0883157cbfe67f0c578708a1bde \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index b6e93ad1f9551c2668a59ac9124fa31afa8a1d1c..ab68e40174d0fe42a116ed46543a45ee2b122aa0 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -11749,6 +11749,7 @@ CREATE TABLE application_settings ( encrypted_openai_api_key_iv bytea, database_max_running_batched_background_migrations integer DEFAULT 2 NOT NULL, silent_mode_enabled boolean DEFAULT false NOT NULL, + package_metadata_purl_types smallint[] DEFAULT '{}'::smallint[], CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_container_registry_pre_import_tags_rate_positive CHECK ((container_registry_pre_import_tags_rate >= (0)::numeric)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), diff --git a/doc/user/admin_area/settings/index.md b/doc/user/admin_area/settings/index.md index 152c35dd50475e930bfea8ac259ec139d6403b43..11c14102efbe71a90461d7b3257dae0099a21e68 100644 --- a/doc/user/admin_area/settings/index.md +++ b/doc/user/admin_area/settings/index.md @@ -66,6 +66,10 @@ The **CI/CD** settings contain: [risks are involved](../../packages/container_registry/reduce_container_registry_storage.md#use-with-external-container-registries) in enabling some of these settings. +## Security and Compliance settings + +- [License compliance settings](security_and_compliance.md#choose-package-registry-metadata-to-sync): Enable or disable synchronization of package metadata by a registry type. + ### Geo **(PREMIUM SELF)** The **Geo** setting contains: diff --git a/doc/user/admin_area/settings/security_and_compliance.md b/doc/user/admin_area/settings/security_and_compliance.md new file mode 100644 index 0000000000000000000000000000000000000000..13abf1027cd411fc67db0c2252af3fd86c064c7f --- /dev/null +++ b/doc/user/admin_area/settings/security_and_compliance.md @@ -0,0 +1,20 @@ +--- +stage: Secure +group: Composition Analysis +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments +type: howto +--- + +# Security and Compliance Admin Area settings **(ULTIMATE SELF)** + +The settings for package metadata synchronization are located in the [Admin Area](index.md). + +## Choose package registry metadata to sync + +To choose the packages you want to synchronize with the GitLab License Database for [License Compliance](../../compliance/license_scanning_of_cyclonedx_files/index.md): + +1. On the top bar, select **Main menu > Admin**. +1. On the left sidebar, select **Settings > Security and Compliance**. +1. Expand **License Compliance**. +1. Select or clear checkboxes for the package registries that you want to sync. +1. Select **Save changes**. diff --git a/doc/user/compliance/license_scanning_of_cyclonedx_files/index.md b/doc/user/compliance/license_scanning_of_cyclonedx_files/index.md index e81951d93d434c1864ee42c78625844d9d0b7141..1ca10ed61db2954e98b7ecdb802c30f0ef3c93a0 100644 --- a/doc/user/compliance/license_scanning_of_cyclonedx_files/index.md +++ b/doc/user/compliance/license_scanning_of_cyclonedx_files/index.md @@ -22,6 +22,7 @@ Licenses not in the SPDX list are reported as "Unknown". License information can Prerequisites: +- Enable [Synchronization with the GitLab License Database](../../admin_area/settings/security_and_compliance.md#choose-package-registry-metadata-to-sync) in Admin Area for the GitLab instance. - Enable [Dependency Scanning](../../application_security/dependency_scanning/index.md#configuration). From the `.gitlab-ci.yml` file, remove the deprecated line `Jobs/License-Scanning.gitlab-ci.yml`, if diff --git a/ee/app/controllers/ee/admin/application_settings_controller.rb b/ee/app/controllers/ee/admin/application_settings_controller.rb index db0223ef2b5373efc5795ff3512fb0312e896f93..8b17f2652e21a5fef000f4e854745e628c2fdf59 100644 --- a/ee/app/controllers/ee/admin/application_settings_controller.rb +++ b/ee/app/controllers/ee/admin/application_settings_controller.rb @@ -22,6 +22,7 @@ module ApplicationSettingsController feature_category :sm_provisioning, [:seat_link_payload] feature_category :source_code_management, [:templates] feature_category :global_search, [:advanced_search] + feature_category :software_composition_analysis, [:security_and_compliance] urgency :low, [:advanced_search, :seat_link_payload] def elasticsearch_reindexing_task @@ -65,7 +66,7 @@ def scim_token end end - EE_VALID_SETTING_PANELS = %w(advanced_search templates).freeze + EE_VALID_SETTING_PANELS = %w(advanced_search templates security_and_compliance).freeze EE_VALID_SETTING_PANELS.each do |action| define_method(action) { perform_update if submitted? } diff --git a/ee/app/helpers/ee/application_settings_helper.rb b/ee/app/helpers/ee/application_settings_helper.rb index 8f1872713f6d37fde7392d42c38354588a1698cb..6c7aaf6bdef1c403c6dda862b4c17dcaff138cd8 100644 --- a/ee/app/helpers/ee/application_settings_helper.rb +++ b/ee/app/helpers/ee/application_settings_helper.rb @@ -219,5 +219,20 @@ def git_abuse_rate_limit_data auto_ban_user_on_excessive_projects_download: auto_ban_users } end + + def sync_purl_types_checkboxes(form) + ::Enums::PackageMetadata.purl_types.keys.map do |name| + checked = @application_setting.package_metadata_purl_types_names.include?(name) + numeric = ::Enums::PackageMetadata.purl_types[name] + + form.gitlab_ui_checkbox_component( + :package_metadata_purl_types, + name, + checkbox_options: { checked: checked, multiple: true, autocomplete: 'off' }, + checked_value: numeric, + unchecked_value: nil + ) + end + end end end diff --git a/ee/app/models/ee/application_setting.rb b/ee/app/models/ee/application_setting.rb index d0e42e9f086b7b12257b0d69337883db3311fbc7..f39337c5140f89dd9cd07470ba100ea1cfcc3992 100644 --- a/ee/app/models/ee/application_setting.rb +++ b/ee/app/models/ee/application_setting.rb @@ -191,6 +191,8 @@ module ApplicationSetting presence: true, if: :product_analytics_enabled + validates :package_metadata_purl_types, inclusion: { in: ::Enums::PackageMetadata.purl_types.values } + alias_attribute :delayed_project_deletion, :delayed_project_removal before_save :update_lock_delayed_project_removal, if: :delayed_group_deletion_changed? @@ -505,6 +507,10 @@ def git_rate_limit_users_alertlist self[:git_rate_limit_users_alertlist].presence || ::User.admins.active.pluck_primary_key end + def package_metadata_purl_types_names + ::Enums::PackageMetadata.purl_types_numerical.values_at(*package_metadata_purl_types) + end + def unique_project_download_limit_enabled? return true if max_number_of_repository_downloads.nonzero? && max_number_of_repository_downloads_within_time_period.nonzero? diff --git a/ee/app/models/package_metadata/sync_configuration.rb b/ee/app/models/package_metadata/sync_configuration.rb index 2f7f905571bdfabab450fac36f70c67ec445def3..37ddd4ffb823634ecdb91216cfff1c53af14d363 100644 --- a/ee/app/models/package_metadata/sync_configuration.rb +++ b/ee/app/models/package_metadata/sync_configuration.rb @@ -21,9 +21,10 @@ class SyncConfiguration }.with_indifferent_access.freeze - def self.all + def self.all_by_enabled_purl_type storage_type = get_storage_type - ::Enums::PackageMetadata.purl_types.map do |purl_type, _| + + permitted_purl_types.map do |purl_type, _| new(storage_type, BUCKET_NAME, VERSION_FORMAT, purl_type) end end @@ -40,6 +41,10 @@ def self.registry_id(purl_type) PURL_TYPE_TO_REGISTRY_ID[purl_type].freeze end + def self.permitted_purl_types + ::Gitlab::CurrentSettings.current_application_settings.package_metadata_purl_types_names + end + attr_accessor :storage_type, :base_uri, :version_format, :purl_type def initialize(storage_type, base_uri, version_format, purl_type) diff --git a/ee/app/services/package_metadata/sync_service.rb b/ee/app/services/package_metadata/sync_service.rb index e9501c35b1661294892e0cac29828ed68909c13b..ecf7e309908f80213cef67c9f70414be608ed4a9 100644 --- a/ee/app/services/package_metadata/sync_service.rb +++ b/ee/app/services/package_metadata/sync_service.rb @@ -7,7 +7,7 @@ class SyncService THROTTLE_RATE = 0.75.seconds def self.execute(signal) - SyncConfiguration.all.each do |config| + SyncConfiguration.all_by_enabled_purl_type.each do |config| if signal.stop? break Gitlab::AppJsonLogger.debug(class: name, message: "Stop signal received before starting #{config.purl_type} sync") diff --git a/ee/app/views/admin/application_settings/_license_compliance.html.haml b/ee/app/views/admin/application_settings/_license_compliance.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..43b4c1a13d78846b287702b025a45875e1c58c2f --- /dev/null +++ b/ee/app/views/admin/application_settings/_license_compliance.html.haml @@ -0,0 +1,14 @@ += gitlab_ui_form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-license-compliance-settings'), html: { class: 'fieldset-form', id: 'license-compliance-settings' } do |f| + = form_errors(@application_setting) + + %fieldset + .form-group + = f.label :package_metadata_purl_types, s_('AdminSettings|Package registry metadata to sync'), class: 'label-bold gl-mb-0' + %span.form-text.gl-mt-0.gl-mb-3#package_metadata_purl_types-help + = _('Package registry types for which metadata is stored, required for License Compliance for CycloneDX files') + = link_to sprite_icon('question-o'), help_page_path("user/compliance/license_scanning_of_cyclonedx_files/index") + = hidden_field_tag 'application_setting[package_metadata_purl_types][]' + - sync_purl_types_checkboxes(f).each do |checkbox| + = checkbox + = f.submit _('Save changes'), pajamas_button: true + diff --git a/ee/app/views/admin/application_settings/security_and_compliance.html.haml b/ee/app/views/admin/application_settings/security_and_compliance.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..00742ba5719a957a6eb7370426ad50c3932a3248 --- /dev/null +++ b/ee/app/views/admin/application_settings/security_and_compliance.html.haml @@ -0,0 +1,14 @@ +- breadcrumb_title _("Security and Compliance") +- page_title _("Security and Compliance") +- add_page_specific_style 'page_bundles/settings' + +%section.settings.as-license-compliance.no-animate#js-license-compliance-settings{ class: ('expanded' if expanded_by_default?), data: { testid: 'admin-license-compliance-settings' } } + .settings-header + %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only + = _('License Compliance') + = render Pajamas::ButtonComponent.new(button_options: { class: 'js-settings-toggle' }) do + = expanded_by_default? ? _('Collapse') : _('Expand') + %p + = _('Settings for the License Compliance feature') + .settings-content + = render 'license_compliance' diff --git a/ee/app/views/layouts/nav/ee/admin/_security_and_compliance_sidebar.html.haml b/ee/app/views/layouts/nav/ee/admin/_security_and_compliance_sidebar.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..093316e40f407628f1e969557ec379f07293dde3 --- /dev/null +++ b/ee/app/views/layouts/nav/ee/admin/_security_and_compliance_sidebar.html.haml @@ -0,0 +1,5 @@ +- if License.feature_available?(:license_scanning) + = nav_link do + = link_to security_and_compliance_admin_application_settings_path, title: _('Security and Compliance'), data: { qa_selector: 'admin_security_and_compliance_link' } do + %span + Security and Compliance diff --git a/ee/config/routes/admin.rb b/ee/config/routes/admin.rb index d367b89dd64e82199ecf31033951caeb8e460571..6c5bb93c1d894521f315481ccb29b5d00d4e04e1 100644 --- a/ee/config/routes/admin.rb +++ b/ee/config/routes/admin.rb @@ -44,7 +44,7 @@ # using `only: []` to keep duplicate routes from being created resource :application_settings, only: [] do get :seat_link_payload - match :templates, :advanced_search, via: [:get, :patch] + match :templates, :advanced_search, :security_and_compliance, via: [:get, :patch] get :geo, to: "geo/settings#show" resource :scim_oauth, only: [:create], controller: :scim_oauth, module: 'application_settings' diff --git a/ee/spec/helpers/ee/application_settings_helper_spec.rb b/ee/spec/helpers/ee/application_settings_helper_spec.rb index eae3de27193993360ffd9b66d1a315ccb3eae3d7..0cd71a75a1e0c0f9c0f3334e832dfa53f77e90b1 100644 --- a/ee/spec/helpers/ee/application_settings_helper_spec.rb +++ b/ee/spec/helpers/ee/application_settings_helper_spec.rb @@ -125,4 +125,33 @@ auto_ban_user_on_excessive_projects_download: 'true' }) end end + + describe '#sync_purl_types_checkboxes', feature_category: :software_composition_analysis do + let_it_be(:application_setting) { build(:application_setting) } + + before do + application_setting.package_metadata_purl_types = [1, 5] + + helper.instance_variable_set(:@application_setting, application_setting) + end + + it 'returns correctly checked purl type checkboxes' do + helper.gitlab_ui_form_for(application_setting, url: '/admin/application_settings/security_and_compliance') do |form| + result = helper.sync_purl_types_checkboxes(form) + + expect(result[0]).to have_checked_field('composer', with: 1) + expect(result[1]).to have_unchecked_field('conan', with: 2) + expect(result[2]).to have_unchecked_field('gem', with: 3) + expect(result[3]).to have_unchecked_field('golang', with: 4) + expect(result[4]).to have_checked_field('maven', with: 5) + expect(result[5]).to have_unchecked_field('npm', with: 6) + expect(result[6]).to have_unchecked_field('nuget', with: 7) + expect(result[7]).to have_unchecked_field('pypi', with: 8) + expect(result[8]).to have_unchecked_field('apk', with: 9) + expect(result[9]).to have_unchecked_field('rpm', with: 10) + expect(result[10]).to have_unchecked_field('deb', with: 11) + expect(result[11]).to have_unchecked_field('cbl_mariner', with: 12) + end + end + end end diff --git a/ee/spec/models/application_setting_spec.rb b/ee/spec/models/application_setting_spec.rb index 9cce4fd63b5e50235728ab8723f1b85e24f73542..6617f747b36d786181dc25996db6be2c148703ad 100644 --- a/ee/spec/models/application_setting_spec.rb +++ b/ee/spec/models/application_setting_spec.rb @@ -453,6 +453,13 @@ it { is_expected.to allow_value(nil).for(:product_analytics_data_collector_host) } end end + + describe 'package_metadata_purl_types', feature_category: :software_composition_analysis do + it { is_expected.to allow_value(1).for(:package_metadata_purl_types) } + it { is_expected.to allow_value(12).for(:package_metadata_purl_types) } + it { is_expected.not_to allow_value(13).for(:package_metadata_purl_types) } + it { is_expected.not_to allow_value(0).for(:package_metadata_purl_types) } + end end describe 'search curation settings after .create_from_defaults', feature_category: :global_search do diff --git a/ee/spec/models/package_metadata/sync_configuration_spec.rb b/ee/spec/models/package_metadata/sync_configuration_spec.rb index fc1d91946efa14bc50e8d0b0933016ce96d1a8d4..8fe37d7e6ab66f47f29cb0fee27b6d528d960f35 100644 --- a/ee/spec/models/package_metadata/sync_configuration_spec.rb +++ b/ee/spec/models/package_metadata/sync_configuration_spec.rb @@ -3,36 +3,64 @@ require 'spec_helper' RSpec.describe PackageMetadata::SyncConfiguration, feature_category: :software_composition_analysis do - describe '.all' do - subject(:registries) { described_class.all } + describe '.all_by_enabled_purl_type' do + subject(:configurations) { described_class.all_by_enabled_purl_type } - it 'returns a configuration instance for each known purl type' do - expect(registries).to match_array([ - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'composer'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'conan'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'gem'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'golang'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'maven'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'npm'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'nuget'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'pypi'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'apk'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'rpm'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'deb'), - have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, - version_format: described_class::VERSION_FORMAT, purl_type: 'cbl_mariner') - ]) + context 'with all purl types allowed to sync' do + before do + # stub application setting with all available at the moment package metadata types + stub_application_setting(package_metadata_purl_types: Enums::PackageMetadata.purl_types.values) + end + + it 'returns a configuration instance for each known purl type' do + expect(configurations).to match_array([ + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'composer'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'conan'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'gem'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'golang'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'maven'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'npm'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'nuget'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'pypi'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'apk'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'rpm'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'deb'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'cbl_mariner') + ]) + end + end + + context 'with some purl types allowed to sync' do + before do + stub_application_setting(package_metadata_purl_types: [1, 5]) + end + + it 'returns a configuration instance only for selected types' do + expect(configurations).to match_array([ + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'composer'), + have_attributes(storage_type: :gcp, base_uri: described_class::BUCKET_NAME, + version_format: described_class::VERSION_FORMAT, purl_type: 'maven') + ]) + end + end + + context 'with none purl types allowed to sync' do + it 'returns an empty array' do + expect(configurations).to be_empty + end end end diff --git a/ee/spec/services/package_metadata/sync_service_spec.rb b/ee/spec/services/package_metadata/sync_service_spec.rb index aea958d6610a68334b28b43afdd7586df899db82..78844f27cd67311213fb3ca7d608c0b64fbed7fd 100644 --- a/ee/spec/services/package_metadata/sync_service_spec.rb +++ b/ee/spec/services/package_metadata/sync_service_spec.rb @@ -114,6 +114,10 @@ subject(:execute) { described_class.execute(stop_signal) } + before do + stub_application_setting(package_metadata_purl_types: Enums::PackageMetadata.purl_types.values) + end + context 'when stop_signal.stop? is false' do let(:should_stop) { false } @@ -135,6 +139,19 @@ execute end end + + context 'when none purl types enabled to sync' do + let(:should_stop) { false } + + before do + stub_application_setting(package_metadata_purl_types: []) + end + + it 'does not proceed' do + expect(described_class).not_to receive(:new) + execute + end + end end describe '.connector_for' do diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 689a1464a62cfd70084aef8ddec9e8685149dbbf..331a90588a93d8ce891dea6e1aea82a619a8bec1 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -3111,6 +3111,9 @@ msgstr "" msgid "AdminSettings|Only enable search after installing the plugin, enabling indexing, and recreating the index." msgstr "" +msgid "AdminSettings|Package registry metadata to sync" +msgstr "" + msgid "AdminSettings|Pause Elasticsearch indexing" msgstr "" @@ -30869,6 +30872,9 @@ msgstr "" msgid "Package registry rate limits" msgstr "" +msgid "Package registry types for which metadata is stored, required for License Compliance for CycloneDX files" +msgstr "" + msgid "Package type" msgstr "" @@ -40894,6 +40900,9 @@ msgstr[1] "" msgid "Settings" msgstr "" +msgid "Settings for the License Compliance feature" +msgstr "" + msgid "Settings|Unable to load the merge request options settings. Try reloading the page." msgstr ""