Commit d5fb657a authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 0366826f 8931be02
...@@ -241,7 +241,7 @@ Dangerfile @gl-quality/eng-prod ...@@ -241,7 +241,7 @@ Dangerfile @gl-quality/eng-prod
/ee/lib/gitlab/ci/reports/dependency_list/ @gitlab-org/secure/composition-analysis-be /ee/lib/gitlab/ci/reports/dependency_list/ @gitlab-org/secure/composition-analysis-be
/ee/lib/gitlab/ci/reports/license_scanning/ @gitlab-org/secure/composition-analysis-be /ee/lib/gitlab/ci/reports/license_scanning/ @gitlab-org/secure/composition-analysis-be
/ee/lib/gitlab/ci/reports/security/ @gitlab-org/secure/composition-analysis-be @gitlab-org/secure/dynamic-analysis-be @gitlab-org/secure/static-analysis-be @gitlab-org/secure/fuzzing-be /ee/lib/gitlab/ci/reports/security/ @gitlab-org/secure/composition-analysis-be @gitlab-org/secure/dynamic-analysis-be @gitlab-org/secure/static-analysis-be @gitlab-org/secure/fuzzing-be
/ee/app/services/ci/run_dast_scan_service.rb @gitlab-org/secure/dynamic-analysis-be /ee/app/services/app_sec/dast/ @gitlab-org/secure/dynamic-analysis-be
[Container Security] [Container Security]
/ee/app/views/projects/threat_monitoring/** @gitlab-org/protect/container-security-frontend /ee/app/views/projects/threat_monitoring/** @gitlab-org/protect/container-security-frontend
......
...@@ -103,6 +103,11 @@ class FinalizeCiBuildsBigintConversion < Gitlab::Database::Migration[1.0] ...@@ -103,6 +103,11 @@ class FinalizeCiBuildsBigintConversion < Gitlab::Database::Migration[1.0]
remove_foreign_key(:ci_resources, TABLE_NAME, column: :build_id, name: 'fk_rails_e169a8e3d5') remove_foreign_key(:ci_resources, TABLE_NAME, column: :build_id, name: 'fk_rails_e169a8e3d5')
end end
# Remove this unexpected FK if it exists - https://gitlab.com/gitlab-org/gitlab/-/issues/341822
if foreign_key_exists?(:ci_sources_pipelines, TABLE_NAME, column: :source_job_id, name: 'fk_3f0c88d7dc')
remove_foreign_key(:ci_sources_pipelines, TABLE_NAME, column: :source_job_id, name: 'fk_3f0c88d7dc')
end
swap_columns swap_columns
end end
......
...@@ -6,16 +6,14 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -6,16 +6,14 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Multiple Databases # Multiple Databases
In order to scale GitLab, the GitLab application database To scale GitLab, the we are
will be [decomposed into multiple [decomposing the GitLab application database into multiple databases](https://gitlab.com/groups/gitlab-org/-/epics/6168).
databases](https://gitlab.com/groups/gitlab-org/-/epics/6168).
## CI Database ## CI/CD Database
Support for configuring the GitLab Rails application to use a distinct > Support for configuring the GitLab Rails application to use a distinct
database for CI tables was added in [GitLab database for CI/CD tables was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64289)
14.1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64289). This in GitLab 14.1. This feature is still under development, and is not ready for production use.
feature is still under development, and is not ready for production use.
By default, GitLab is configured to use only one main database. To By default, GitLab is configured to use only one main database. To
opt-in to use a main database, and CI database, modify the opt-in to use a main database, and CI database, modify the
...@@ -92,8 +90,8 @@ test: &test ...@@ -92,8 +90,8 @@ test: &test
### Migrations ### Migrations
Any migrations that affect `Ci::CiDatabaseRecord` models Place any migrations that affect `Ci::CiDatabaseRecord` models
and their tables must be placed in two directories for now: and their tables in two directories:
- `db/migrate` - `db/migrate`
- `db/ci_migrate` - `db/ci_migrate`
......
...@@ -10,6 +10,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -10,6 +10,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/221259) to GitLab Free in 13.3. > - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/221259) to GitLab Free in 13.3.
> - Support for Composer 2.0 [added](https://gitlab.com/gitlab-org/gitlab/-/issues/259840) in GitLab Free 13.10. > - Support for Composer 2.0 [added](https://gitlab.com/gitlab-org/gitlab/-/issues/259840) in GitLab Free 13.10.
WARNING:
The Composer package registry for GitLab is under development and isn't ready for production use due to
limited functionality. This [epic](https://gitlab.com/groups/gitlab-org/-/epics/6817) details the remaining
work and timelines to make it production ready.
Publish [Composer](https://getcomposer.org/) packages in your project's Package Registry. Publish [Composer](https://getcomposer.org/) packages in your project's Package Registry.
Then, install the packages whenever you need to use them as a dependency. Then, install the packages whenever you need to use them as a dependency.
......
...@@ -9,6 +9,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -9,6 +9,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/8248) in GitLab Premium 12.6. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/8248) in GitLab Premium 12.6.
> - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/221259) to GitLab Free in 13.3. > - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/221259) to GitLab Free in 13.3.
WARNING:
The Conan package registry for GitLab is under development and isn't ready for production use due to
limited functionality. This [epic](https://gitlab.com/groups/gitlab-org/-/epics/6816) details the remaining
work and timelines to make it production ready.
Publish Conan packages in your project's Package Registry. Then install the Publish Conan packages in your project's Package Registry. Then install the
packages whenever you need to use them as a dependency. packages whenever you need to use them as a dependency.
......
...@@ -12,7 +12,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -12,7 +12,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w
WARNING: WARNING:
The Debian package registry for GitLab is under development and isn't ready for production use due to The Debian package registry for GitLab is under development and isn't ready for production use due to
limited functionality. limited functionality. This [epic](https://gitlab.com/groups/gitlab-org/-/epics/6057) details the remaining
work and timelines to make it production ready.
Publish Debian packages in your project's Package Registry. Then install the Publish Debian packages in your project's Package Registry. Then install the
packages whenever you need to use them as a dependency. packages whenever you need to use them as a dependency.
......
...@@ -9,10 +9,14 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -9,10 +9,14 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/27376) in GitLab Premium 13.1. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/27376) in GitLab Premium 13.1.
> - It's deployed behind a feature flag, disabled by default. > - It's deployed behind a feature flag, disabled by default.
> - It's disabled for GitLab.com. > - It's disabled for GitLab.com.
> - It's not recommended for production use.
> - To use it in GitLab self-managed instances, ask a GitLab administrator to [enable it](#enable-the-go-proxy). > - To use it in GitLab self-managed instances, ask a GitLab administrator to [enable it](#enable-the-go-proxy).
> - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/221259) to GitLab Free in 13.3. > - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/221259) to GitLab Free in 13.3.
WARNING:
The Go package registry for GitLab is under development and isn't ready for production use due to
limited functionality. This [epic](https://gitlab.com/groups/gitlab-org/-/epics/3043) details the remaining
work and timelines to make it production ready.
With the Go proxy for GitLab, every project in GitLab can be fetched with the With the Go proxy for GitLab, every project in GitLab can be fetched with the
[Go proxy protocol](https://proxy.golang.org/). [Go proxy protocol](https://proxy.golang.org/).
......
...@@ -8,6 +8,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -8,6 +8,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/18997) in GitLab 14.1. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/18997) in GitLab 14.1.
WARNING:
The Helm chart registry for GitLab is under development and isn't ready for production use due to
limited functionality. This [epic](https://gitlab.com/groups/gitlab-org/-/epics/6366) details the remaining
work and timelines to make it production ready.
Publish Helm packages in your project's Package Registry. Then install the Publish Helm packages in your project's Package Registry. Then install the
packages whenever you need to use them as a dependency. packages whenever you need to use them as a dependency.
......
...@@ -10,20 +10,31 @@ The GitLab [Package Registry](package_registry/index.md) acts as a private or pu ...@@ -10,20 +10,31 @@ The GitLab [Package Registry](package_registry/index.md) acts as a private or pu
for a variety of common package managers. You can publish and share for a variety of common package managers. You can publish and share
packages, which can be easily consumed as a dependency in downstream projects. packages, which can be easily consumed as a dependency in downstream projects.
WARNING:
Not all package manager formats are ready for production use. To view each format's status, see the
table's **Status** column.
The Package Registry supports the following formats: The Package Registry supports the following formats:
| Package type | GitLab version | | Package type | GitLab version | Status |
| ------------ | -------------- | | ------------ | -------------- |------- |
| [Composer](composer_repository/index.md) | 13.2+ | | [Maven](maven_repository/index.md) | 11.3+ | Stable |
| [Conan](conan_repository/index.md) | 12.6+ | | [npm](npm_registry/index.md) | 11.7+ | Stable |
| [Go](go_proxy/index.md) | 13.1+ | | [NuGet](nuget_repository/index.md) | 12.8+ | Stable |
| [Helm](helm_repository/index.md) | 14.1+ | | [PyPI](pypi_repository/index.md) | 12.10+ | Stable |
| [Maven](maven_repository/index.md) | 11.3+ | | [Generic packages](generic_packages/index.md) | 13.5+ | Stable |
| [npm](npm_registry/index.md) | 11.7+ | | [Composer](composer_repository/index.md) | 13.2+ | [Beta](https://gitlab.com/groups/gitlab-org/-/epics/6817) |
| [NuGet](nuget_repository/index.md) | 12.8+ | | [Conan](conan_repository/index.md) | 12.6+ | [Beta](https://gitlab.com/groups/gitlab-org/-/epics/6816) |
| [PyPI](pypi_repository/index.md) | 12.10+ | | [Helm](helm_repository/index.md) | 14.1+ | [Beta](https://gitlab.com/groups/gitlab-org/-/epics/6366) |
| [Generic packages](generic_packages/index.md) | 13.5+ | | [Debian](debian_repository/index.md) | 14.2+ | [Alpha](https://gitlab.com/groups/gitlab-org/-/epics/6057) |
| [Ruby gems](rubygems_registry/index.md) | 13.10+ | | [Go](go_proxy/index.md) | 13.1+ | [Alpha](https://gitlab.com/groups/gitlab-org/-/epics/3043) |
| [Ruby gems](rubygems_registry/index.md) | 13.10+ | [Alpha](https://gitlab.com/groups/gitlab-org/-/epics/3200) |
Status:
- Alpha: behind a feature flag and not officially supported.
- Beta: several known issues that may prevent expected use.
- Stable: ready for production use.
You can also use the [API](../../api/packages.md) to administer the Package Registry. You can also use the [API](../../api/packages.md) to administer the Package Registry.
...@@ -40,12 +51,12 @@ guides you through the process. ...@@ -40,12 +51,12 @@ guides you through the process.
| CocoaPods | [#36890](https://gitlab.com/gitlab-org/gitlab/-/issues/36890) | | CocoaPods | [#36890](https://gitlab.com/gitlab-org/gitlab/-/issues/36890) |
| Conda | [#36891](https://gitlab.com/gitlab-org/gitlab/-/issues/36891) | | Conda | [#36891](https://gitlab.com/gitlab-org/gitlab/-/issues/36891) |
| CRAN | [#36892](https://gitlab.com/gitlab-org/gitlab/-/issues/36892) | | CRAN | [#36892](https://gitlab.com/gitlab-org/gitlab/-/issues/36892) |
| Debian | [Draft: Merge Request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50438) |
| Opkg | [#36894](https://gitlab.com/gitlab-org/gitlab/-/issues/36894) | | Opkg | [#36894](https://gitlab.com/gitlab-org/gitlab/-/issues/36894) |
| P2 | [#36895](https://gitlab.com/gitlab-org/gitlab/-/issues/36895) | | P2 | [#36895](https://gitlab.com/gitlab-org/gitlab/-/issues/36895) |
| Puppet | [#36897](https://gitlab.com/gitlab-org/gitlab/-/issues/36897) | | Puppet | [#36897](https://gitlab.com/gitlab-org/gitlab/-/issues/36897) |
| RPM | [#5932](https://gitlab.com/gitlab-org/gitlab/-/issues/5932) | | RPM | [#5932](https://gitlab.com/groups/gitlab-org/-/epics/5128) |
| SBT | [#36898](https://gitlab.com/gitlab-org/gitlab/-/issues/36898) | | SBT | [#36898](https://gitlab.com/gitlab-org/gitlab/-/issues/36898) |
| Swift | [#12233](https://gitlab.com/gitlab-org/gitlab/-/issues/12233) |
| Vagrant | [#36899](https://gitlab.com/gitlab-org/gitlab/-/issues/36899) | | Vagrant | [#36899](https://gitlab.com/gitlab-org/gitlab/-/issues/36899) |
<!-- vale gitlab.Spelling = YES --> <!-- vale gitlab.Spelling = YES -->
......
...@@ -9,8 +9,9 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -9,8 +9,9 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/803) in [GitLab Free](https://about.gitlab.com/pricing/) 13.10. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/803) in [GitLab Free](https://about.gitlab.com/pricing/) 13.10.
WARNING: WARNING:
The Ruby gems registry for GitLab is under development and isn't ready for production use due to The Ruby gems package registry for GitLab is under development and isn't ready for production use due to
limited functionality. limited functionality. This [epic](https://gitlab.com/groups/gitlab-org/-/epics/3200) details the remaining
work and timelines to make it production ready.
You can publish Ruby gems in your project's Package Registry, then install the packages when you You can publish Ruby gems in your project's Package Registry, then install the packages when you
need to use them as a dependency. Although you can push gems to the registry, you cannot install need to use them as a dependency. Although you can push gems to the registry, you cannot install
......
...@@ -55,7 +55,7 @@ module Mutations ...@@ -55,7 +55,7 @@ module Mutations
end end
def create_on_demand_dast_scan(project, dast_profile) def create_on_demand_dast_scan(project, dast_profile)
::DastOnDemandScans::CreateService.new( ::AppSec::Dast::Scans::CreateService.new(
container: project, container: project,
current_user: current_user, current_user: current_user,
params: { dast_profile: dast_profile } params: { dast_profile: dast_profile }
......
...@@ -71,7 +71,7 @@ module Mutations ...@@ -71,7 +71,7 @@ module Mutations
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def create_on_demand_dast_scan(project, dast_site_profile, dast_scanner_profile) def create_on_demand_dast_scan(project, dast_site_profile, dast_scanner_profile)
::DastOnDemandScans::CreateService.new( ::AppSec::Dast::Scans::CreateService.new(
container: project, container: project,
current_user: current_user, current_user: current_user,
params: { params: {
......
...@@ -60,7 +60,7 @@ module AppSec ...@@ -60,7 +60,7 @@ module AppSec
end end
def create_on_demand_scan(dast_profile) def create_on_demand_scan(dast_profile)
::DastOnDemandScans::CreateService.new( ::AppSec::Dast::Scans::CreateService.new(
container: container, container: container,
current_user: current_user, current_user: current_user,
params: { dast_profile: dast_profile } params: { dast_profile: dast_profile }
......
...@@ -130,7 +130,7 @@ module AppSec ...@@ -130,7 +130,7 @@ module AppSec
end end
def create_scan(dast_profile) def create_scan(dast_profile)
::DastOnDemandScans::CreateService.new( ::AppSec::Dast::Scans::CreateService.new(
container: container, container: container,
current_user: current_user, current_user: current_user,
params: { dast_profile: dast_profile } params: { dast_profile: dast_profile }
......
# frozen_string_literal: true
module AppSec
module Dast
module Scans
class CreateService < BaseContainerService
def execute
return ServiceResponse.error(message: 'Insufficient permissions') unless allowed?
create_pipeline
rescue KeyError => err
ServiceResponse.error(message: err.message.capitalize)
end
private
def allowed?
container.licensed_feature_available?(:security_on_demand_scans)
end
def success_response(pipeline)
pipeline_url = Rails.application.routes.url_helpers.project_pipeline_url(
container,
pipeline
)
ServiceResponse.success(
payload: {
pipeline: pipeline,
pipeline_url: pipeline_url
}
)
end
def create_pipeline
config_result = AppSec::Dast::ScanConfigs::BuildService.new(container: container, current_user: current_user, params: params).execute
return config_result unless config_result.success?
result = ::AppSec::Dast::Scans::RunService.new(container, current_user).execute(**config_result.payload)
return success_response(result.payload) if result.success?
result
end
end
end
end
end
# frozen_string_literal: true
module AppSec
module Dast
module Scans
class RunService < BaseService
def execute(branch:, ci_configuration:, dast_profile: nil, dast_site_profile: nil, dast_scanner_profile: nil)
return ServiceResponse.error(message: 'Insufficient permissions') unless allowed?
service = Ci::CreatePipelineService.new(project, current_user, ref: branch)
response = service.execute(:ondemand_dast_scan, content: ci_configuration) do |pipeline|
pipeline.dast_profile = dast_profile
end
pipeline = response.payload
if pipeline.created_successfully?
ServiceResponse.success(payload: pipeline)
else
ServiceResponse.error(message: pipeline.full_error_messages)
end
end
private
def allowed?
Ability.allowed?(current_user, :create_on_demand_dast_scan, project)
end
end
end
end
end
# frozen_string_literal: true
module Ci
class RunDastScanService < BaseService
def execute(branch:, ci_configuration:, dast_profile: nil, dast_site_profile: nil, dast_scanner_profile: nil)
return ServiceResponse.error(message: 'Insufficient permissions') unless allowed?
service = Ci::CreatePipelineService.new(project, current_user, ref: branch)
response = service.execute(:ondemand_dast_scan, content: ci_configuration) do |pipeline|
pipeline.dast_profile = dast_profile
end
pipeline = response.payload
if pipeline.created_successfully?
ServiceResponse.success(payload: pipeline)
else
ServiceResponse.error(message: pipeline.full_error_messages)
end
end
private
def allowed?
Ability.allowed?(current_user, :create_on_demand_dast_scan, project)
end
end
end
# frozen_string_literal: true
module DastOnDemandScans
class CreateService < BaseContainerService
def execute
return ServiceResponse.error(message: 'Insufficient permissions') unless allowed?
create_pipeline
rescue KeyError => err
ServiceResponse.error(message: err.message.capitalize)
end
private
def allowed?
container.feature_available?(:security_on_demand_scans)
end
def success_response(pipeline)
pipeline_url = Rails.application.routes.url_helpers.project_pipeline_url(
container,
pipeline
)
ServiceResponse.success(
payload: {
pipeline: pipeline,
pipeline_url: pipeline_url
}
)
end
def create_pipeline
config_result = AppSec::Dast::ScanConfigs::BuildService.new(container: container, current_user: current_user, params: params).execute
return config_result unless config_result.success?
result = ::Ci::RunDastScanService.new(container, current_user).execute(**config_result.payload)
return success_response(result.payload) if result.success?
result
end
end
end
...@@ -53,7 +53,7 @@ module Security ...@@ -53,7 +53,7 @@ module Security
dast_scanner_profile = find_dast_scanner_profile(container, action[:scanner_profile]) dast_scanner_profile = find_dast_scanner_profile(container, action[:scanner_profile])
branches.each do |branch| branches.each do |branch|
::DastOnDemandScans::CreateService.new( ::AppSec::Dast::Scans::CreateService.new(
container: container, container: container,
current_user: current_user, current_user: current_user,
params: { params: {
......
...@@ -37,7 +37,7 @@ module AppSec ...@@ -37,7 +37,7 @@ module AppSec
end end
def service(schedule) def service(schedule)
::DastOnDemandScans::CreateService.new( ::AppSec::Dast::Scans::CreateService.new(
container: schedule.project, container: schedule.project,
current_user: schedule.owner, current_user: schedule.owner,
params: { params: {
......
...@@ -65,15 +65,11 @@ module EE ...@@ -65,15 +65,11 @@ module EE
end end
def group_context?(parent) def group_context?(parent)
strong_memoize(:group_context) do parent.is_a?(Group)
parent.is_a?(Group)
end
end end
def project_context?(parent) def project_context?(parent)
strong_memoize(:project_context) do parent.is_a?(Project)
parent.is_a?(Project)
end
end end
def references_in(text, pattern = ::Iteration.reference_pattern) def references_in(text, pattern = ::Iteration.reference_pattern)
......
...@@ -83,7 +83,7 @@ RSpec.describe Mutations::DastOnDemandScans::Create do ...@@ -83,7 +83,7 @@ RSpec.describe Mutations::DastOnDemandScans::Create do
ci_configuration: kind_of(String) ci_configuration: kind_of(String)
) )
expect_any_instance_of(::Ci::RunDastScanService).to receive(:execute).with(args).and_call_original expect_any_instance_of(::AppSec::Dast::Scans::RunService).to receive(:execute).with(args).and_call_original
subject subject
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe DastOnDemandScans::CreateService do RSpec.describe AppSec::Dast::Scans::CreateService do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:dast_site_profile) { create(:dast_site_profile, project: project) } let_it_be(:dast_site_profile) { create(:dast_site_profile, project: project) }
...@@ -18,12 +18,12 @@ RSpec.describe DastOnDemandScans::CreateService do ...@@ -18,12 +18,12 @@ RSpec.describe DastOnDemandScans::CreateService do
).execute ).execute
end end
shared_examples 'a service that calls Ci::RunDastScanService' do shared_examples 'a service that calls AppSec::Dast::Scans::RunService' do
it 'delegates pipeline creation to Ci::RunDastScanService', :aggregate_failures do it 'delegates pipeline creation to AppSec::Dast::Scans::RunService', :aggregate_failures do
service = double(Ci::RunDastScanService) service = double(AppSec::Dast::Scans::RunService)
response = ServiceResponse.error(message: 'Stubbed response') response = ServiceResponse.error(message: 'Stubbed response')
expect(Ci::RunDastScanService).to receive(:new).and_return(service) expect(AppSec::Dast::Scans::RunService).to receive(:new).and_return(service)
expect(service).to receive(:execute).with(expected_params).and_return(response) expect(service).to receive(:execute).with(expected_params).and_return(response)
subject subject
...@@ -61,7 +61,7 @@ RSpec.describe DastOnDemandScans::CreateService do ...@@ -61,7 +61,7 @@ RSpec.describe DastOnDemandScans::CreateService do
expect(subject.payload[:pipeline_url]).to be_a(String) expect(subject.payload[:pipeline_url]).to be_a(String)
end end
it_behaves_like 'a service that calls Ci::RunDastScanService' do it_behaves_like 'a service that calls AppSec::Dast::Scans::RunService' do
let(:expected_params) do let(:expected_params) do
hash_including( hash_including(
dast_profile: nil, dast_profile: nil,
...@@ -107,7 +107,7 @@ RSpec.describe DastOnDemandScans::CreateService do ...@@ -107,7 +107,7 @@ RSpec.describe DastOnDemandScans::CreateService do
expect(subject.status).to eq(:success) expect(subject.status).to eq(:success)
end end
it_behaves_like 'a service that calls Ci::RunDastScanService' do it_behaves_like 'a service that calls AppSec::Dast::Scans::RunService' do
let(:expected_params) { hash_including(dast_profile: dast_profile) } let(:expected_params) { hash_including(dast_profile: dast_profile) }
end end
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::RunDastScanService do RSpec.describe AppSec::Dast::Scans::RunService do
include Ci::TemplateHelpers include Ci::TemplateHelpers
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
......
...@@ -34,8 +34,8 @@ RSpec.describe Security::SecurityOrchestrationPolicies::RuleScheduleService do ...@@ -34,8 +34,8 @@ RSpec.describe Security::SecurityOrchestrationPolicies::RuleScheduleService do
end end
context 'when scan type is dast' do context 'when scan type is dast' do
it 'invokes DastOnDemandScans::CreateService' do it 'invokes AppSec::Dast::Scans::CreateService' do
expect(::DastOnDemandScans::CreateService).to receive(:new).twice.and_call_original expect(::AppSec::Dast::Scans::CreateService).to receive(:new).twice.and_call_original
service.execute(schedule) service.execute(schedule)
end end
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.shared_examples 'it delegates scan creation to another service' do RSpec.shared_examples 'it delegates scan creation to another service' do
it 'calls DastOnDemandScans::CreateService' do it 'calls AppSec::Dast::Scans::CreateService' do
expect(DastOnDemandScans::CreateService).to receive(:new).with(hash_including(params: delegated_params)).and_call_original expect(AppSec::Dast::Scans::CreateService).to receive(:new).with(hash_including(params: delegated_params)).and_call_original
subject subject
end end
......
...@@ -9,11 +9,11 @@ RSpec.describe AppSec::Dast::ProfileScheduleWorker do ...@@ -9,11 +9,11 @@ RSpec.describe AppSec::Dast::ProfileScheduleWorker do
let(:worker) { described_class.new } let(:worker) { described_class.new }
let(:logger) { worker.send(:logger) } let(:logger) { worker.send(:logger) }
let(:service) { instance_double(::DastOnDemandScans::CreateService) } let(:service) { instance_double(::AppSec::Dast::Scans::CreateService) }
let(:service_result) { ServiceResponse.success } let(:service_result) { ServiceResponse.success }
before do before do
allow(::DastOnDemandScans::CreateService) allow(::AppSec::Dast::Scans::CreateService)
.to receive(:new) .to receive(:new)
.and_return(service) .and_return(service)
allow(service).to receive(:execute) allow(service).to receive(:execute)
...@@ -97,7 +97,7 @@ RSpec.describe AppSec::Dast::ProfileScheduleWorker do ...@@ -97,7 +97,7 @@ RSpec.describe AppSec::Dast::ProfileScheduleWorker do
end end
it 'executes the rule schedule service' do it 'executes the rule schedule service' do
expect(::DastOnDemandScans::CreateService).not_to receive(:new) expect(::AppSec::Dast::Scans::CreateService).not_to receive(:new)
subject subject
end end
......
...@@ -5,8 +5,6 @@ module Banzai ...@@ -5,8 +5,6 @@ module Banzai
module References module References
# HTML filter that replaces milestone references with links. # HTML filter that replaces milestone references with links.
class MilestoneReferenceFilter < AbstractReferenceFilter class MilestoneReferenceFilter < AbstractReferenceFilter
include Gitlab::Utils::StrongMemoize
self.reference_type = :milestone self.reference_type = :milestone
self.object_class = Milestone self.object_class = Milestone
...@@ -63,21 +61,15 @@ module Banzai ...@@ -63,21 +61,15 @@ module Banzai
end end
def valid_context?(parent) def valid_context?(parent)
strong_memoize(:valid_context) do group_context?(parent) || project_context?(parent)
group_context?(parent) || project_context?(parent)
end
end end
def group_context?(parent) def group_context?(parent)
strong_memoize(:group_context) do parent.is_a?(Group)
parent.is_a?(Group)
end
end end
def project_context?(parent) def project_context?(parent)
strong_memoize(:project_context) do parent.is_a?(Project)
parent.is_a?(Project)
end
end end
def references_in(text, pattern = Milestone.reference_pattern) def references_in(text, pattern = Milestone.reference_pattern)
......
...@@ -437,6 +437,19 @@ RSpec.describe Banzai::Filter::References::MilestoneReferenceFilter do ...@@ -437,6 +437,19 @@ RSpec.describe Banzai::Filter::References::MilestoneReferenceFilter do
expect(reference_filter(act, context).to_html).to eq exp expect(reference_filter(act, context).to_html).to eq exp
end end
end end
context 'when referencing both project and group milestones' do
let(:milestone) { create(:milestone, project: project) }
let(:group_milestone) { create(:milestone, title: 'group_milestone', group: group) }
it 'links to valid references' do
links = reference_filter("See #{milestone.to_reference(full: true)} and #{group_milestone.to_reference}", context).css('a')
expect(links.length).to eq(2)
expect(links[0].attr('href')).to eq(urls.milestone_url(milestone))
expect(links[1].attr('href')).to eq(urls.milestone_url(group_milestone))
end
end
end end
context 'when milestone is open' do context 'when milestone is open' do
......
# frozen_string_literal: true
require 'spec_helper'
require_migration!('finalize_ci_builds_bigint_conversion')
RSpec.describe FinalizeCiBuildsBigintConversion, :migration, schema: 20210907182359 do
context 'with an unexpected FK fk_3f0c88d7dc' do
it 'removes the FK and migrates successfully' do
# Add the unexpected FK
subject.add_foreign_key(:ci_sources_pipelines, :ci_builds, column: :source_job_id, name: 'fk_3f0c88d7dc')
expect { migrate! }.to change { subject.foreign_key_exists?(:ci_sources_pipelines, :ci_builds, column: :source_job_id, name: 'fk_3f0c88d7dc') }.from(true).to(false)
# Additional check: The actually expected FK should still exist
expect(subject.foreign_key_exists?(:ci_sources_pipelines, :ci_builds, column: :source_job_id, name: 'fk_be5624bf37')).to be_truthy
end
end
end
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
- "./spec/lib/api/entities/package_spec.rb" - "./spec/lib/api/entities/package_spec.rb"
- "./spec/lib/gitlab/background_migration/migrate_legacy_artifacts_spec.rb" - "./spec/lib/gitlab/background_migration/migrate_legacy_artifacts_spec.rb"
- "./spec/mailers/emails/pipelines_spec.rb" - "./spec/mailers/emails/pipelines_spec.rb"
- "./spec/migrations/20210907211557_finalize_ci_builds_bigint_conversion_spec.rb"
- "./spec/migrations/cleanup_legacy_artifact_migration_spec.rb" - "./spec/migrations/cleanup_legacy_artifact_migration_spec.rb"
- "./spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb" - "./spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb"
- "./spec/migrations/re_schedule_latest_pipeline_id_population_with_all_security_related_artifact_types_spec.rb" - "./spec/migrations/re_schedule_latest_pipeline_id_population_with_all_security_related_artifact_types_spec.rb"
......
...@@ -3819,10 +3819,10 @@ core-js-pure@^3.0.0: ...@@ -3819,10 +3819,10 @@ core-js-pure@^3.0.0:
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813" resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813"
integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA== integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==
core-js@^3.18.0: core-js@^3.18.1:
version "3.18.0" version "3.18.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.18.0.tgz#9af3f4a6df9ba3428a3fb1b171f1503b3f40cc49" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.18.1.tgz#289d4be2ce0085d40fc1244c0b1a54c00454622f"
integrity sha512-WJeQqq6jOYgVgg4NrXKL0KLQhi0CT4ZOCvFL+3CQ5o7I6J8HkT5wd53EadMfqTDp1so/MT1J+w2ujhWcCJtN7w== integrity sha512-vJlUi/7YdlCZeL6fXvWNaLUPh/id12WXj3MbkMw5uOyF0PfWPBNOCNbs53YqgrvtujLNlt9JQpruyIKkUZ+PKA==
core-js@~2.3.0: core-js@~2.3.0:
version "2.3.0" version "2.3.0"
......
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