Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-21 21:07:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-21 21:07:57 +0300
commitc0b718a0dbd99e6c0d30e5bc55bdcf4a12946375 (patch)
tree8ad3691912d91d8cf7b3931f68a4284ae7b5995c /lib
parent5dc70663c4ff1feb215428ce50673b5b646f9809 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/api.rb3
-rw-r--r--lib/api/ci/secure_files.rb37
-rw-r--r--lib/api/entities/ci/secure_file.rb15
-rw-r--r--lib/extracts_ref.rb16
-rw-r--r--lib/gitlab/ci/parsers/security/common.rb8
-rw-r--r--lib/sidebars/projects/menus/repository_menu.rb8
6 files changed, 67 insertions, 20 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb
index 3c88d2483d2..c62a0a60eab 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -186,6 +186,7 @@ module API
mount ::API::Ci::ResourceGroups
mount ::API::Ci::Runner
mount ::API::Ci::Runners
+ mount ::API::Ci::SecureFiles
mount ::API::Ci::Pipelines
mount ::API::Ci::PipelineSchedules
mount ::API::Ci::Triggers
@@ -276,6 +277,8 @@ module API
mount ::API::AwardEmoji
mount ::API::Boards
mount ::API::Ci::JobArtifacts
+ mount ::API::Ci::Pipelines
+ mount ::API::Ci::PipelineSchedules
mount ::API::Ci::SecureFiles
mount ::API::ComposerPackages
mount ::API::ConanInstancePackages
diff --git a/lib/api/ci/secure_files.rb b/lib/api/ci/secure_files.rb
index dd628a3413f..0cc20c967db 100644
--- a/lib/api/ci/secure_files.rb
+++ b/lib/api/ci/secure_files.rb
@@ -16,11 +16,15 @@ module API
default_format :json
params do
- requires :id, types: [String, Integer], desc: 'The ID or URL-encoded path of the project'
+ requires :id, types: [String, Integer], desc: 'The ID or URL-encoded path of the project owned by the
+ authenticated user'
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'List all Secure Files for a Project'
+ desc 'Get list of secure files in a project' do
+ success Entities::Ci::SecureFile
+ tags %w[secure_files]
+ end
params do
use :pagination
end
@@ -30,9 +34,13 @@ module API
present paginate(secure_files), with: Entities::Ci::SecureFile
end
- desc 'Get an individual Secure File'
+ desc 'Get the details of a specific secure file in a project' do
+ success Entities::Ci::SecureFile
+ tags %w[secure_files]
+ failure [{ code: 404, message: '404 Not found' }]
+ end
params do
- requires :id, type: Integer, desc: 'The Secure File ID'
+ requires :id, type: Integer, desc: 'The ID of a secure file'
end
route_setting :authentication, basic_auth_personal_access_token: true, job_token_allowed: true
@@ -41,7 +49,10 @@ module API
present secure_file, with: Entities::Ci::SecureFile
end
- desc 'Download a Secure File'
+ desc 'Download secure file' do
+ failure [{ code: 404, message: '404 Not found' }]
+ tags %w[secure_files]
+ end
route_setting :authentication, basic_auth_personal_access_token: true, job_token_allowed: true
get ':id/secure_files/:secure_file_id/download' do
secure_file = user_project.secure_files.find(params[:secure_file_id])
@@ -58,10 +69,15 @@ module API
authorize! :admin_secure_files, user_project
end
- desc 'Upload a Secure File'
+ desc 'Create a secure file' do
+ success Entities::Ci::SecureFile
+ tags %w[secure_files]
+ failure [{ code: 400, message: '400 Bad Request' }]
+ end
params do
- requires :name, type: String, desc: 'The name of the file'
- requires :file, types: [Rack::Multipart::UploadedFile, ::API::Validations::Types::WorkhorseFile], desc: 'The secure file to be uploaded', documentation: { type: 'file' }
+ requires :name, type: String, desc: 'The name of the file being uploaded. The filename must be unique within
+ the project'
+ requires :file, types: [Rack::Multipart::UploadedFile, ::API::Validations::Types::WorkhorseFile], desc: 'The secure file being uploaded', documentation: { type: 'file' }
end
route_setting :authentication, basic_auth_personal_access_token: true, job_token_allowed: true
post ':id/secure_files' do
@@ -84,7 +100,10 @@ module API
end
end
- desc 'Delete an individual Secure File'
+ desc 'Remove a secure file' do
+ tags %w[secure_files]
+ failure [{ code: 404, message: '404 Not found' }]
+ end
route_setting :authentication, basic_auth_personal_access_token: true, job_token_allowed: true
delete ':id/secure_files/:secure_file_id' do
secure_file = user_project.secure_files.find(params[:secure_file_id])
diff --git a/lib/api/entities/ci/secure_file.rb b/lib/api/entities/ci/secure_file.rb
index d957e4488fd..a234ada6f82 100644
--- a/lib/api/entities/ci/secure_file.rb
+++ b/lib/api/entities/ci/secure_file.rb
@@ -4,13 +4,14 @@ module API
module Entities
module Ci
class SecureFile < Grape::Entity
- expose :id
- expose :name
- expose :checksum
- expose :checksum_algorithm
- expose :created_at
- expose :expires_at
- expose :metadata
+ expose :id, documentation: { type: 'integer', example: 123 }
+ expose :name, documentation: { type: 'string', example: 'upload-keystore.jks' }
+ expose :checksum,
+documentation: { type: 'string', example: '16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac' }
+ expose :checksum_algorithm, documentation: { type: 'string', example: 'sha256' }
+ expose :created_at, documentation: { type: 'dateTime', example: '2022-02-22T22:22:22.222Z' }
+ expose :expires_at, documentation: { type: 'dateTime', example: '2022-09-21T14:56:00.000Z' }
+ expose :metadata, documentation: { type: 'Hash', example: { "id" => "75949910542696343243264405377658443914" } }
end
end
end
diff --git a/lib/extracts_ref.rb b/lib/extracts_ref.rb
index 9799116038e..f22996df0a5 100644
--- a/lib/extracts_ref.rb
+++ b/lib/extracts_ref.rb
@@ -64,10 +64,16 @@ module ExtractsRef
def assign_ref_vars
@id, @ref, @path = extract_ref_path
@repo = repository_container.repository
-
raise InvalidPathError if @ref.match?(/\s/)
- @commit = @repo.commit(@ref) if @ref.present?
+ return unless @ref.present?
+
+ @commit = if ref_type && Feature.enabled?(:use_ref_type_parameter, @repo.project)
+ @fully_qualified_ref = %(refs/#{ref_type}/#{@ref})
+ @repo.commit(@fully_qualified_ref)
+ else
+ @repo.commit(@ref)
+ end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
@@ -82,6 +88,12 @@ module ExtractsRef
[id, ref, path]
end
+ def ref_type
+ return unless params[:ref_type].present?
+
+ params[:ref_type] == 'tags' ? 'tags' : 'heads'
+ end
+
private
def extract_raw_ref(id)
diff --git a/lib/gitlab/ci/parsers/security/common.rb b/lib/gitlab/ci/parsers/security/common.rb
index 0ac012b9fd1..67817c9f832 100644
--- a/lib/gitlab/ci/parsers/security/common.rb
+++ b/lib/gitlab/ci/parsers/security/common.rb
@@ -65,8 +65,14 @@ module Gitlab
)
end
+ # New Oj parsers are not thread safe, therefore,
+ # we need to initialize them for each thread.
+ def introspect_parser
+ Thread.current[:introspect_parser] ||= Oj::Introspect.new(filter: "remediations")
+ end
+
def report_data
- @report_data ||= Gitlab::Json.parse!(json_data)
+ @report_data ||= introspect_parser.parse(json_data)
end
def report_version
diff --git a/lib/sidebars/projects/menus/repository_menu.rb b/lib/sidebars/projects/menus/repository_menu.rb
index 1b46323089c..c5245cd944d 100644
--- a/lib/sidebars/projects/menus/repository_menu.rb
+++ b/lib/sidebars/projects/menus/repository_menu.rb
@@ -56,9 +56,15 @@ module Sidebars
end
def commits_menu_item
+ link = if Feature.enabled?(:use_ref_type_parameter, context.project)
+ project_commits_path(context.project, context.current_ref, ref_type: context.try(:ref_type) || 'heads')
+ else
+ project_commits_path(context.project, context.current_ref)
+ end
+
::Sidebars::MenuItem.new(
title: _('Commits'),
- link: project_commits_path(context.project, context.current_ref),
+ link: link,
active_routes: { controller: %w(commit commits) },
item_id: :commits,
container_html_options: { id: 'js-onboarding-commits-link' }