From f986ce9ffa56e25d0a3010c78d9481664742d766 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 23 Mar 2021 18:09:05 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../javascripts/pages/admin/services/edit/index.js | 6 +-- .../javascripts/pipelines/components/dag/dag.vue | 4 ++ .../components/graph/stage_column_component.vue | 19 +++++++- .../pipelines/components/unwrapping_utils.js | 2 +- .../javascripts/releases/components/app_show.vue | 56 ++++++++++++++++++---- app/assets/javascripts/releases/mount_show.js | 28 ++++++----- .../releases/stores/modules/detail/actions.js | 4 +- app/controllers/graphql_controller.rb | 5 +- app/controllers/projects/forks_controller.rb | 10 +++- app/controllers/projects/pipelines_controller.rb | 1 + app/controllers/projects/releases_controller.rb | 1 - .../token_authenticatable_strategies/encrypted.rb | 8 +--- app/serializers/fork_namespace_entity.rb | 2 +- app/validators/json_schema_validator.rb | 11 ++--- .../application_setting_kroki_formats.json | 1 + .../json_schemas/build_metadata_secrets.json | 1 + .../json_schemas/build_report_result_data.json | 1 + .../build_report_result_data_tests.json | 1 + app/validators/json_schemas/codeclimate.json | 1 + .../daily_build_group_report_result_data.json | 1 + app/validators/json_schemas/debian_fields.json | 1 + app/validators/json_schemas/git_trailers.json | 1 + ...http_integration_payload_attribute_mapping.json | 1 + .../sast_ui_schema.json | 1 + 24 files changed, 119 insertions(+), 48 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/pages/admin/services/edit/index.js b/app/assets/javascripts/pages/admin/services/edit/index.js index 3d692ef4dcc..b8080ddff77 100644 --- a/app/assets/javascripts/pages/admin/services/edit/index.js +++ b/app/assets/javascripts/pages/admin/services/edit/index.js @@ -1,6 +1,4 @@ import IntegrationSettingsForm from '~/integrations/integration_settings_form'; -document.addEventListener('DOMContentLoaded', () => { - const integrationSettingsForm = new IntegrationSettingsForm('.js-integration-settings-form'); - integrationSettingsForm.init(); -}); +const integrationSettingsForm = new IntegrationSettingsForm('.js-integration-settings-form'); +integrationSettingsForm.init(); diff --git a/app/assets/javascripts/pipelines/components/dag/dag.vue b/app/assets/javascripts/pipelines/components/dag/dag.vue index e44dedfe2ee..16fb931ec2b 100644 --- a/app/assets/javascripts/pipelines/components/dag/dag.vue +++ b/app/assets/javascripts/pipelines/components/dag/dag.vue @@ -50,6 +50,10 @@ export default { }; }, update(data) { + if (!data?.project?.pipeline) { + return this.graphData; + } + const { stages: { nodes: stages }, } = data.project.pipeline; diff --git a/app/assets/javascripts/pipelines/components/graph/stage_column_component.vue b/app/assets/javascripts/pipelines/components/graph/stage_column_component.vue index 0a762563114..66467dbc994 100644 --- a/app/assets/javascripts/pipelines/components/graph/stage_column_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/stage_column_component.vue @@ -1,5 +1,6 @@ diff --git a/app/assets/javascripts/releases/mount_show.js b/app/assets/javascripts/releases/mount_show.js index f3ed7d6c5ff..7272880197a 100644 --- a/app/assets/javascripts/releases/mount_show.js +++ b/app/assets/javascripts/releases/mount_show.js @@ -1,26 +1,28 @@ import Vue from 'vue'; -import Vuex from 'vuex'; +import VueApollo from 'vue-apollo'; +import createDefaultClient from '~/lib/graphql'; import ReleaseShowApp from './components/app_show.vue'; -import createStore from './stores'; -import createDetailModule from './stores/modules/detail'; -Vue.use(Vuex); +Vue.use(VueApollo); + +const apolloProvider = new VueApollo({ + defaultClient: createDefaultClient(), +}); export default () => { const el = document.getElementById('js-show-release-page'); - const store = createStore({ - modules: { - detail: createDetailModule(el.dataset), - }, - featureFlags: { - graphqlIndividualReleasePage: Boolean(gon.features?.graphqlIndividualReleasePage), - }, - }); + if (!el) return false; + + const { projectPath, tagName } = el.dataset; return new Vue({ el, - store, + apolloProvider, + provide: { + fullPath: projectPath, + tagName, + }, render: (h) => h(ReleaseShowApp), }); }; diff --git a/app/assets/javascripts/releases/stores/modules/detail/actions.js b/app/assets/javascripts/releases/stores/modules/detail/actions.js index 5fa002706c6..8dc2083dd2b 100644 --- a/app/assets/javascripts/releases/stores/modules/detail/actions.js +++ b/app/assets/javascripts/releases/stores/modules/detail/actions.js @@ -43,7 +43,7 @@ export const fetchRelease = ({ commit, state, rootState }) => { }) .catch((error) => { commit(types.RECEIVE_RELEASE_ERROR, error); - createFlash(s__('Release|Something went wrong while getting the release details')); + createFlash(s__('Release|Something went wrong while getting the release details.')); }); } @@ -54,7 +54,7 @@ export const fetchRelease = ({ commit, state, rootState }) => { }) .catch((error) => { commit(types.RECEIVE_RELEASE_ERROR, error); - createFlash(s__('Release|Something went wrong while getting the release details')); + createFlash(s__('Release|Something went wrong while getting the release details.')); }); }; diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb index 82005c548f2..a13ec1daddb 100644 --- a/app/controllers/graphql_controller.rb +++ b/app/controllers/graphql_controller.rb @@ -146,8 +146,7 @@ class GraphqlController < ApplicationController end def logs - RequestStore.store[:graphql_logs].to_h - .except(:duration_s, :query_string) - .merge(operation_name: params[:operationName]) + RequestStore.store[:graphql_logs].to_a + .map { |log| log.except(:duration_s, :query_string) } end end diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 005bc2a385b..b999110181b 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -44,13 +44,17 @@ class Projects::ForksController < Projects::ApplicationController def new respond_to do |format| format.html do - @own_namespace = current_user.namespace if fork_service.valid_fork_targets.include?(current_user.namespace) + @own_namespace = current_user.namespace if can_fork_to?(current_user.namespace) @project = project end format.json do namespaces = load_namespaces_with_associations - [project.namespace] + namespaces = [current_user.namespace] + namespaces if + Feature.enabled?(:fork_project_form, project, default_enabled: :yaml) && + can_fork_to?(current_user.namespace) + render json: { namespaces: ForkNamespaceSerializer.new.represent(namespaces, project: project, current_user: current_user, memberships: memberships_hash) } @@ -78,6 +82,10 @@ class Projects::ForksController < Projects::ApplicationController private + def can_fork_to?(namespace) + ForkTargetsFinder.new(@project, current_user).execute.id_in(current_user.namespace).any? + end + def load_forks forks = ForkProjectsFinder.new( project, diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 35d138fc27b..e1c2efc3760 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -15,6 +15,7 @@ class Projects::PipelinesController < Projects::ApplicationController before_action do push_frontend_feature_flag(:new_pipeline_form, project, default_enabled: :yaml) push_frontend_feature_flag(:pipeline_graph_layers_view, project, type: :development, default_enabled: :yaml) + push_frontend_feature_flag(:pipeline_filter_jobs, project, default_enabled: :yaml) push_frontend_feature_flag(:graphql_pipeline_details, project, type: :development, default_enabled: :yaml) push_frontend_feature_flag(:graphql_pipeline_details_users, current_user, type: :development, default_enabled: :yaml) push_frontend_feature_flag(:jira_for_vulnerabilities, project, type: :development, default_enabled: :yaml) diff --git a/app/controllers/projects/releases_controller.rb b/app/controllers/projects/releases_controller.rb index 614bada09ed..26382856761 100644 --- a/app/controllers/projects/releases_controller.rb +++ b/app/controllers/projects/releases_controller.rb @@ -12,7 +12,6 @@ class Projects::ReleasesController < Projects::ApplicationController push_frontend_feature_flag(:graphql_release_data, project, default_enabled: true) push_frontend_feature_flag(:graphql_milestone_stats, project, default_enabled: true) push_frontend_feature_flag(:graphql_releases_page, project, default_enabled: true) - push_frontend_feature_flag(:graphql_individual_release_page, project, default_enabled: true) end before_action :authorize_update_release!, only: %i[edit update] before_action :authorize_create_release!, only: :new diff --git a/app/models/concerns/token_authenticatable_strategies/encrypted.rb b/app/models/concerns/token_authenticatable_strategies/encrypted.rb index 672402ee4d6..b59396a323c 100644 --- a/app/models/concerns/token_authenticatable_strategies/encrypted.rb +++ b/app/models/concerns/token_authenticatable_strategies/encrypted.rb @@ -85,18 +85,12 @@ module TokenAuthenticatableStrategies end def find_by_encrypted_token(token, unscoped) - nonce = Feature.enabled?(:dynamic_nonce_creation) ? find_hashed_iv(token) : Gitlab::CryptoHelper::AES256_GCM_IV_STATIC + nonce = Gitlab::CryptoHelper::AES256_GCM_IV_STATIC encrypted_value = Gitlab::CryptoHelper.aes256_gcm_encrypt(token, nonce: nonce) relation(unscoped).find_by(encrypted_field => encrypted_value) end - def find_hashed_iv(token) - token_record = TokenWithIv.find_by_plaintext_token(token) - - token_record&.iv || Gitlab::CryptoHelper::AES256_GCM_IV_STATIC - end - def insecure_strategy @insecure_strategy ||= TokenAuthenticatableStrategies::Insecure .new(klass, token_field, options) diff --git a/app/serializers/fork_namespace_entity.rb b/app/serializers/fork_namespace_entity.rb index abfaf4be811..fc238fa3958 100644 --- a/app/serializers/fork_namespace_entity.rb +++ b/app/serializers/fork_namespace_entity.rb @@ -23,7 +23,7 @@ class ForkNamespaceEntity < Grape::Entity end expose :relative_path do |namespace| - polymorphic_path(namespace) + group_path(namespace) end expose :markdown_description do |namespace| diff --git a/app/validators/json_schema_validator.rb b/app/validators/json_schema_validator.rb index 742839f5f5b..8dc6265f471 100644 --- a/app/validators/json_schema_validator.rb +++ b/app/validators/json_schema_validator.rb @@ -12,7 +12,6 @@ class JsonSchemaValidator < ActiveModel::EachValidator FILENAME_ALLOWED = /\A[a-z0-9_-]*\Z/.freeze FilenameError = Class.new(StandardError) - JSON_VALIDATOR_MAX_DRAFT_VERSION = 4 BASE_DIRECTORY = %w(app validators json_schemas).freeze def initialize(options) @@ -35,11 +34,11 @@ class JsonSchemaValidator < ActiveModel::EachValidator attr_reader :base_directory def valid_schema?(value) - if draft_version > JSON_VALIDATOR_MAX_DRAFT_VERSION - JSONSchemer.schema(Pathname.new(schema_path)).valid?(value) - else - JSON::Validator.validate(schema_path, value) - end + validator.valid?(value) + end + + def validator + @validator ||= JSONSchemer.schema(Pathname.new(schema_path)) end def schema_path diff --git a/app/validators/json_schemas/application_setting_kroki_formats.json b/app/validators/json_schemas/application_setting_kroki_formats.json index 460dc74069f..4dfa710abea 100644 --- a/app/validators/json_schemas/application_setting_kroki_formats.json +++ b/app/validators/json_schemas/application_setting_kroki_formats.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "description": "Kroki formats", "type": "object", "properties": { diff --git a/app/validators/json_schemas/build_metadata_secrets.json b/app/validators/json_schemas/build_metadata_secrets.json index e745a266777..799e7ab1642 100644 --- a/app/validators/json_schemas/build_metadata_secrets.json +++ b/app/validators/json_schemas/build_metadata_secrets.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "description": "CI builds metadata secrets", "type": "object", "patternProperties": { diff --git a/app/validators/json_schemas/build_report_result_data.json b/app/validators/json_schemas/build_report_result_data.json index 0fb4fd6d0b7..0a12c9c39a7 100644 --- a/app/validators/json_schemas/build_report_result_data.json +++ b/app/validators/json_schemas/build_report_result_data.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "description": "Build report result data", "type": "object", "properties": { diff --git a/app/validators/json_schemas/build_report_result_data_tests.json b/app/validators/json_schemas/build_report_result_data_tests.json index b38559e727f..610070fde5f 100644 --- a/app/validators/json_schemas/build_report_result_data_tests.json +++ b/app/validators/json_schemas/build_report_result_data_tests.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "description": "Build report result data tests", "type": "object", "properties": { diff --git a/app/validators/json_schemas/codeclimate.json b/app/validators/json_schemas/codeclimate.json index 56056c62c4e..dc43eab6290 100644 --- a/app/validators/json_schemas/codeclimate.json +++ b/app/validators/json_schemas/codeclimate.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "description": "Codequality used by codeclimate parser", "type": "object", "required": ["description", "fingerprint", "severity", "location"], diff --git a/app/validators/json_schemas/daily_build_group_report_result_data.json b/app/validators/json_schemas/daily_build_group_report_result_data.json index 2524ac63050..2b073506375 100644 --- a/app/validators/json_schemas/daily_build_group_report_result_data.json +++ b/app/validators/json_schemas/daily_build_group_report_result_data.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "description": "Daily build group report result data", "type": "object", "properties": { diff --git a/app/validators/json_schemas/debian_fields.json b/app/validators/json_schemas/debian_fields.json index b9f6ad2b31d..ae1a2726ea2 100644 --- a/app/validators/json_schemas/debian_fields.json +++ b/app/validators/json_schemas/debian_fields.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "description": "Debian fields", "type": "object", "patternProperties": { diff --git a/app/validators/json_schemas/git_trailers.json b/app/validators/json_schemas/git_trailers.json index 18ac97226a7..384eb280765 100644 --- a/app/validators/json_schemas/git_trailers.json +++ b/app/validators/json_schemas/git_trailers.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "description": "Git trailer key/value pairs", "type": "object", "patternProperties": { diff --git a/app/validators/json_schemas/http_integration_payload_attribute_mapping.json b/app/validators/json_schemas/http_integration_payload_attribute_mapping.json index a194daf5e45..7aebc959169 100644 --- a/app/validators/json_schemas/http_integration_payload_attribute_mapping.json +++ b/app/validators/json_schemas/http_integration_payload_attribute_mapping.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "patternProperties": { ".*": { diff --git a/app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json b/app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json index 08442565931..99961d7264b 100644 --- a/app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json +++ b/app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "global": [ { "field" : "SECURE_ANALYZERS_PREFIX", -- cgit v1.2.3