Skip to content

Commit 17e561f

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 1edce67 commit 17e561f

File tree

17 files changed

+246
-9
lines changed

17 files changed

+246
-9
lines changed

.rubocop_manual_todo.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,7 @@ Gitlab/NamespacedClass:
18841884
- 'app/models/issue_email_participant.rb'
18851885
- 'app/models/issue_link.rb'
18861886
- 'app/models/issue_user_mention.rb'
1887+
- 'app/models/iteration.rb'
18871888
- 'app/models/jira_connect_installation.rb'
18881889
- 'app/models/jira_connect_subscription.rb'
18891890
- 'app/models/jira_import_state.rb'
@@ -2695,7 +2696,6 @@ Gitlab/NamespacedClass:
26952696
- 'ee/app/models/issuable_metric_image.rb'
26962697
- 'ee/app/models/issuable_sla.rb'
26972698
- 'ee/app/models/issuables_analytics.rb'
2698-
- 'ee/app/models/iteration.rb'
26992699
- 'ee/app/models/iteration_note.rb'
27002700
- 'ee/app/models/ldap_group_link.rb'
27012701
- 'ee/app/models/ldap_key.rb'

GITALY_SERVER_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8752fc1097114316889560502579ddf477a20a2d
1+
1724a973d59c30e92e73953f0b34701e34dff6eb

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ group :development, :test do
398398
gem 'parallel', '~> 1.19', require: false
399399

400400
gem 'rblineprof', '~> 0.3.6', platform: :mri, require: false
401+
402+
gem 'test_file_finder', '~> 0.1.3'
401403
end
402404

403405
group :development, :test, :danger do

Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,8 @@ GEM
12331233
terser (1.0.2)
12341234
execjs (>= 0.3.0, < 3)
12351235
test-prof (0.12.0)
1236+
test_file_finder (0.1.3)
1237+
faraday (~> 1.0.1)
12361238
text (1.3.1)
12371239
thin (1.8.0)
12381240
daemons (~> 1.0, >= 1.0.9)
@@ -1601,6 +1603,7 @@ DEPENDENCIES
16011603
sys-filesystem (~> 1.1.6)
16021604
terser (= 1.0.2)
16031605
test-prof (~> 0.12.0)
1606+
test_file_finder (~> 0.1.3)
16041607
thin (~> 1.8.0)
16051608
thrift (>= 0.14.0)
16061609
timecop (~> 0.9.1)

app/models/iteration.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
# Placeholder class for model that is implemented in EE
4+
class Iteration < ApplicationRecord
5+
self.table_name = 'sprints'
6+
7+
def self.reference_prefix
8+
'*iteration:'
9+
end
10+
11+
def self.reference_pattern
12+
nil
13+
end
14+
end
15+
16+
Iteration.prepend_if_ee('::EE::Iteration')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Update Ruby from 2.5 to 2.7 in Dockerfile templates
3+
merge_request: 59345
4+
author: Takuya Noguchi
5+
type: changed

config/feature_flags/development/geo_pipeline_artifact_replication.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/326228
55
milestone: '13.11'
66
type: development
77
group: group::geo
8-
default_enabled: false
8+
default_enabled: true

doc/api/graphql/reference/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3128,7 +3128,7 @@ Represents an external issue.
31283128
| `minimumReverificationInterval` | [`Int`](#int) | The interval (in days) in which the repository verification is valid. Once expired, it will be reverified. |
31293129
| `name` | [`String`](#string) | The unique identifier for this Geo node. |
31303130
| `packageFileRegistries` | [`PackageFileRegistryConnection`](#packagefileregistryconnection) | Package file registries of the GeoNode. |
3131-
| `pipelineArtifactRegistries` | [`PipelineArtifactRegistryConnection`](#pipelineartifactregistryconnection) | Find pipeline artifact registries on this Geo node. Available only when feature flag `geo_pipeline_artifact_replication` is enabled. |
3131+
| `pipelineArtifactRegistries` | [`PipelineArtifactRegistryConnection`](#pipelineartifactregistryconnection) | Find pipeline artifact registries on this Geo node. |
31323132
| `primary` | [`Boolean`](#boolean) | Indicates whether this Geo node is the primary. |
31333133
| `reposMaxCapacity` | [`Int`](#int) | The maximum concurrency of repository backfill for this secondary node. |
31343134
| `selectiveSyncNamespaces` | [`NamespaceConnection`](#namespaceconnection) | The namespaces that should be synced, if `selective_sync_type` == `namespaces`. |

doc/development/rake_tasks.md

+18
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,24 @@ To run several tests inside one directory:
152152

153153
- `bin/rspec spec/requests/api/` for the RSpec tests if you want to test API only
154154

155+
### Run RSpec tests which failed in Merge Request pipeline on your machine
156+
157+
If your Merge Request pipeline failed with RSpec test failures,
158+
you can run all the failed tests on your machine with the following Rake task:
159+
160+
```shell
161+
bin/rake spec:merge_request_rspec_failure
162+
```
163+
164+
There are a few caveats for this Rake task:
165+
166+
- You need to be on the same branch on your machine as the source branch of the Merge Request.
167+
- The pipeline must have been completed.
168+
- You may need to wait for the test report to be parsed and retry again.
169+
170+
This Rake task depends on the [unit test reports](../ci/unit_test_reports.md) feature,
171+
which only gets parsed when it is requested for the first time.
172+
155173
### Speed up tests, Rake tasks, and migrations
156174

157175
[Spring](https://github.com/rails/spring) is a Rails application pre-loader. It

doc/user/application_security/container_scanning/index.md

+79-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,85 @@ To allowlist specific vulnerabilities, follow these steps:
250250
1. Set `GIT_STRATEGY: fetch` in your `.gitlab-ci.yml` file by following the instructions in
251251
[overriding the container scanning template](#overriding-the-container-scanning-template).
252252
1. Define the allowlisted vulnerabilities in a YAML file named `vulnerability-allowlist.yml`. This must use
253-
the format described in the [allowlist example file](https://gitlab.com/gitlab-org/security-products/analyzers/klar/-/raw/master/testdata/vulnerability-allowlist.yml).
254-
1. Add the `vulnerability-allowlist.yml` file to your project's Git repository.
253+
the format described in [vulnerability-allowlist.yml data format](#vulnerability-allowlistyml-data-format).
254+
1. Add the `vulnerability-allowlist.yml` file to the root folder of your project's Git repository.
255+
256+
#### vulnerability-allowlist.yml data format
257+
258+
The `vulnerability-allowlist.yml` file is a YAML file that specifies a list of CVE IDs of vulnerabilities that are **allowed** to exist, because they're _false positives_, or they're _not applicable_.
259+
260+
If a matching entry is found in the `vulnerability-allowlist.yml` file, the following happens:
261+
262+
- The vulnerability **is not included** when the analyzer generates the `gl-container-scanning-report.json` file.
263+
- The Security tab of the pipeline **does not show** the vulnerability. It is not included in the JSON file, which is the source of truth for the Security tab.
264+
265+
Example `vulnerability-allowlist.yml` file:
266+
267+
```yaml
268+
generalallowlist:
269+
CVE-2019-8696:
270+
CVE-2014-8166: cups
271+
CVE-2017-18248:
272+
images:
273+
registry.gitlab.com/gitlab-org/security-products/dast/webgoat-8.0@sha256:
274+
CVE-2018-4180:
275+
your.private.registry:5000/centos:
276+
CVE-2015-1419: libxml2
277+
CVE-2015-1447:
278+
```
279+
280+
This example excludes from `gl-container-scanning-report.json`:
281+
282+
1. All vulnerabilities with CVE IDs: _CVE-2019-8696_, _CVE-2014-8166_, _CVE-2017-18248_.
283+
1. All vulnerabilities found in the `registry.gitlab.com/gitlab-org/security-products/dast/webgoat-8.0@sha256` container image with CVE ID _CVE-2018-4180_.
284+
1. All vulnerabilities found in `your.private.registry:5000/centos` container with CVE IDs _CVE-2015-1419_, _CVE-2015-1447_.
285+
286+
##### File format
287+
288+
- `generalallowlist` block allows you to specify CVE IDs globally. All vulnerabilities with matching CVE IDs are excluded from the scan report.
289+
290+
- `images` block allows you to specify CVE IDs for each container image independently. All vulnerabilities from the given image with matching CVE IDs are excluded from the scan report. The image name is retrieved from one of the environment variables used to specify the Docker image to be scanned, such as `$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG` or `DOCKER_IMAGE`. The image provided in this block **must** match this value and **must not** include the tag value. For example, if you specify the image to be scanned using `DOCKER_IMAGE=alpine:3.7`, then you would use `alpine` in the `images` block, but you cannot use `alpine:3.7`.
291+
292+
You can specify container image in multiple ways:
293+
294+
- as image name only (ie. `centos`).
295+
- as full image name with registry hostname (ie. `your.private.registry:5000/centos`).
296+
- as full image name with registry hostname and sha256 label (ie. `registry.gitlab.com/gitlab-org/security-products/dast/webgoat-8.0@sha256`).
297+
298+
NOTE:
299+
The string after CVE ID (`cups` and `libxml2` in the previous example) is an optional comment format. It has **no impact** on the handling of vulnerabilities. You can include comments to describe the vulnerability.
300+
301+
##### Container scanning job log format
302+
303+
You can verify the results of your scan and the correctness of your `vulnerability-allowlist.yml` file by looking
304+
at the logs that are produced by the container scanning analyzer in `container_scanning` job details.
305+
306+
The log contains a list of found vulnerabilities as a table, for example:
307+
308+
```plainttext
309+
+------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+
310+
| STATUS | CVE SEVERITY | PACKAGE NAME | PACKAGE VERSION | CVE DESCRIPTION |
311+
+------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+
312+
| Approved | High CVE-2019-3462 | apt | 1.4.8 | Incorrect sanitation of the 302 redirect field in HTTP transport metho |
313+
| | | | | d of apt versions 1.4.8 and earlier can lead to content injection by a |
314+
| | | | | MITM attacker, potentially leading to remote code execution on the ta |
315+
| | | | | rget machine. |
316+
+------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+
317+
| Unapproved | Medium CVE-2020-27350 | apt | 1.4.8 | APT had several integer overflows and underflows while parsing .deb pa |
318+
| | | | | ckages, aka GHSL-2020-168 GHSL-2020-169, in files apt-pkg/contrib/extr |
319+
| | | | | acttar.cc, apt-pkg/deb/debfile.cc, and apt-pkg/contrib/arfile.cc. This |
320+
| | | | | issue affects: apt 1.2.32ubuntu0 versions prior to 1.2.32ubuntu0.2; 1 |
321+
| | | | | .6.12ubuntu0 versions prior to 1.6.12ubuntu0.2; 2.0.2ubuntu0 versions |
322+
| | | | | prior to 2.0.2ubuntu0.2; 2.1.10ubuntu0 versions prior to 2.1.10ubuntu0 |
323+
| | | | | .1; |
324+
+------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+
325+
| Unapproved | Medium CVE-2020-3810 | apt | 1.4.8 | Missing input validation in the ar/tar implementations of APT before v |
326+
| | | | | ersion 2.1.2 could result in denial of service when processing special |
327+
| | | | | ly crafted deb files. |
328+
+------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+
329+
```
330+
331+
Vulnerabilities in the log are marked as `Approved` when the corresponding CVE ID is added to the `vulnerability-allowlist.yml` file.
255332

256333
### Running container scanning in an offline environment
257334

lib/tasks/spec.rake

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
return if Rails.env.production?
44

5+
require_relative '../../tooling/merge_request_rspec_failure_rake_task'
6+
57
namespace :spec do
68
desc 'GitLab | RSpec | Run unit tests'
79
RSpec::Core::RakeTask.new(:unit, :rspec_opts) do |t, args|
@@ -24,11 +26,19 @@ namespace :spec do
2426
t.rspec_opts = args[:rspec_opts]
2527
end
2628

29+
desc 'GitLab | RSpec | Run merge request RSpec failures'
30+
Tooling::MergeRequestRspecFailureRakeTask.new(:merge_request_rspec_failure, :rspec_opts) do |t, args|
31+
t.pattern = t.rspec_failures_on_merge_request
32+
t.rspec_opts = args[:rspec_opts]
33+
end
34+
2735
desc 'Run the code examples in spec/requests/api'
2836
RSpec::Core::RakeTask.new(:api) do |t|
2937
t.pattern = 'spec/requests/api/**/*_spec.rb'
3038
end
3139

40+
private
41+
3242
def require_test_level
3343
require_relative '../../tooling/quality/test_level'
3444
end

qa/qa/resource/merge_request.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def initialize
6262
@labels = []
6363
@file_name = "added_file-#{SecureRandom.hex(8)}.txt"
6464
@file_content = "File Added"
65-
@target_branch = "master"
65+
@target_branch = project.default_branch
6666
@target_new_branch = true
6767
@no_preparation = false
6868
@wait_for_merge = true

spec/tooling/merge_request_spec.rb

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
require 'webmock/rspec'
4+
5+
require_relative '../../tooling/merge_request'
6+
require_relative '../support/helpers/next_instance_of'
7+
8+
RSpec.describe Tooling::MergeRequest do
9+
let(:project_path) { 'gitlab-org/gitlab' }
10+
let(:branch_name) { 'my-branch' }
11+
let(:merge_request_iid) { 123 }
12+
let(:merge_requests) { [{ 'iid' => merge_request_iid }] }
13+
14+
describe '.for' do
15+
let(:stub_api) do
16+
stub_request(:get, "https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/merge_requests")
17+
.and_return(body: merge_requests)
18+
end
19+
20+
before do
21+
stub_api.with(query: { source_branch: branch_name, order_by: 'updated_at', sort: 'desc' })
22+
end
23+
24+
it 'fetches merge request for local branch in the given GitLab project path' do
25+
merge_request = described_class.for(branch: branch_name, project_path: project_path)
26+
27+
expect(merge_request.iid).to eq(merge_request_iid)
28+
expect(stub_api).to have_been_requested.once
29+
end
30+
end
31+
end

tooling/merge_request.rb

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
require 'faraday'
4+
require 'faraday_middleware'
5+
6+
module Tooling
7+
class MergeRequest
8+
GITLAB_API_URL_TEMPLATE = 'https://gitlab.com/api/v4/projects/%{project_path}/merge_requests'
9+
10+
def self.for(branch:, project_path:)
11+
url = format(GITLAB_API_URL_TEMPLATE, { project_path: URI.encode_www_form_component(project_path) })
12+
13+
conn = Faraday.new(url) do |conn|
14+
conn.request :json
15+
conn.response :json, content_type: /\bjson$/
16+
conn.adapter Faraday.default_adapter
17+
end
18+
19+
response = conn.get do |req|
20+
req.params[:source_branch] = branch
21+
req.params[:order_by] = 'updated_at'
22+
req.params[:sort] = 'desc'
23+
end
24+
25+
new(response.body.first)
26+
end
27+
28+
attr_reader :merge_request
29+
30+
def initialize(merge_request)
31+
@merge_request = merge_request
32+
end
33+
34+
def iid
35+
merge_request['iid']
36+
end
37+
end
38+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
require 'test_file_finder'
4+
require_relative './merge_request'
5+
6+
module Tooling
7+
class MergeRequestRspecFailureRakeTask < RSpec::Core::RakeTask
8+
PROJECT_PATH = 'gitlab-org/gitlab'
9+
10+
def run_task(_verbose)
11+
if pattern.empty?
12+
puts "No rspec failures in the merge request."
13+
return
14+
end
15+
16+
super
17+
end
18+
19+
def rspec_failures_on_merge_request
20+
test_file_finder = TestFileFinder::FileFinder.new
21+
test_file_finder.use TestFileFinder::MappingStrategies::GitlabMergeRequestRspecFailure.new(project_path: PROJECT_PATH, merge_request_iid: merge_request.iid)
22+
test_file_finder.test_files
23+
rescue TestFileFinder::TestReportError => e
24+
abort e.message
25+
end
26+
27+
private
28+
29+
def merge_request
30+
@merge_request ||= Tooling::MergeRequest.for(branch: current_branch, project_path: PROJECT_PATH)
31+
end
32+
33+
def current_branch
34+
@current_branch ||= `git branch --show-current`.strip
35+
end
36+
end
37+
end

vendor/Dockerfile/Ruby-alpine.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.5-alpine
1+
FROM ruby:2.7-alpine
22

33
# Edit with nodejs, mysql-client, postgresql-client, sqlite3, etc. for your needs.
44
# Or delete entirely if not needed.

vendor/Dockerfile/Ruby.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.5
1+
FROM ruby:2.7
22

33
# Edit with nodejs, mysql-client, postgresql-client, sqlite3, etc. for your needs.
44
# Or delete entirely if not needed.

0 commit comments

Comments
 (0)