diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-23 18:11:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-23 18:11:47 +0300 |
commit | 750a63ac4cc7acbecff3b8d22232cb1c15af34fb (patch) | |
tree | c61c790252548a3909466e3dcfe2a98208764fd3 /app | |
parent | f94cd1d0fb5c0b42ec12a8db02ec90227bb98879 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/ci/pipeline_schedules/components/table/cells/pipeline_schedule_actions.vue | 3 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/components/app.vue | 32 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/components/graphql/get_mr_codequality_and_security_reports.query.graphql (renamed from app/assets/javascripts/diffs/components/graphql/get_mr_codequality_reports.query.graphql) | 26 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/index.js | 5 | ||||
-rw-r--r-- | app/assets/stylesheets/page_bundles/work_items.scss | 2 | ||||
-rw-r--r-- | app/graphql/resolvers/ci/catalog/resources_resolver.rb | 4 | ||||
-rw-r--r-- | app/helpers/blob_helper.rb | 2 | ||||
-rw-r--r-- | app/models/ci/catalog/listing.rb | 51 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 5 | ||||
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/repository.rb | 4 | ||||
-rw-r--r-- | app/presenters/projects/security/configuration_presenter.rb | 4 | ||||
-rw-r--r-- | app/services/google_cloud/generate_pipeline_service.rb | 2 | ||||
-rw-r--r-- | app/services/security/ci_configuration/sast_parser_service.rb | 8 |
14 files changed, 92 insertions, 60 deletions
diff --git a/app/assets/javascripts/ci/pipeline_schedules/components/table/cells/pipeline_schedule_actions.vue b/app/assets/javascripts/ci/pipeline_schedules/components/table/cells/pipeline_schedule_actions.vue index ed7c2bbeb73..78df7298f4f 100644 --- a/app/assets/javascripts/ci/pipeline_schedules/components/table/cells/pipeline_schedule_actions.vue +++ b/app/assets/javascripts/ci/pipeline_schedules/components/table/cells/pipeline_schedule_actions.vue @@ -61,6 +61,7 @@ export default { v-if="canPlay" v-gl-tooltip :title="$options.i18n.playTooltip" + :aria-label="$options.i18n.playTooltip" icon="play" data-testid="play-pipeline-schedule-btn" @click="$emit('playPipelineSchedule', schedule.id)" @@ -78,6 +79,7 @@ export default { v-gl-tooltip :href="editPathWithIdParam" :title="$options.i18n.editTooltip" + :aria-label="$options.i18n.editTooltip" icon="pencil" data-testid="edit-pipeline-schedule-btn" /> @@ -85,6 +87,7 @@ export default { v-if="canRemove" v-gl-tooltip :title="$options.i18n.deleteTooltip" + :aria-label="$options.i18n.deleteTooltip" icon="remove" variant="danger" data-testid="delete-pipeline-schedule-btn" diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index 554c338fa5b..a389ab8e355 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -56,7 +56,7 @@ import HiddenFilesWarning from './hidden_files_warning.vue'; import NoChanges from './no_changes.vue'; import VirtualScrollerScrollSync from './virtual_scroller_scroll_sync'; import DiffsFileTree from './diffs_file_tree.vue'; -import getMRCodequalityReports from './graphql/get_mr_codequality_reports.query.graphql'; +import getMRCodequalityAndSecurityReports from './graphql/get_mr_codequality_and_security_reports.query.graphql'; export default { name: 'DiffsApp', @@ -101,10 +101,10 @@ export default { required: false, default: '', }, - endpointSast: { - type: String, + sastReportAvailable: { + type: Boolean, required: false, - default: '', + default: false, }, endpointCodequality: { type: String, @@ -139,13 +139,15 @@ export default { }; }, apollo: { - getMRCodequalityReports: { - query: getMRCodequalityReports, + getMRCodequalityAndSecurityReports: { + query: getMRCodequalityAndSecurityReports, variables() { return { fullPath: this.projectPath, iid: this.iid }; }, skip() { - return !this.endpointCodequality || !this.sastReportsInInlineDiff; + const codeQualityBoolean = Boolean(this.endpointCodequality); + + return !this.sastReportsInInlineDiff || (!codeQualityBoolean && !this.sastReportAvailable); }, update(data) { if (data?.project?.mergeRequest?.codequalityReportsComparer?.report?.newErrors) { @@ -156,10 +158,14 @@ export default { ), ); } + + if (data.project?.mergeRequest?.sastReport?.report) { + this.$store.commit('diffs/SET_SAST_DATA', data.project.mergeRequest.sastReport.report); + } }, error() { createAlert({ - message: __('Something went wrong fetching the CodeQuality Findings. Please try again!'), + message: __('Something went wrong fetching the Scanner Findings. Please try again!'), }); }, }, @@ -305,10 +311,6 @@ export default { this.setCodequalityEndpoint(this.endpointCodequality); } - if (this.endpointSast) { - this.setSastEndpoint(this.endpointSast); - } - if (this.shouldShow) { this.fetchData(); } @@ -389,7 +391,6 @@ export default { ...mapActions('diffs', [ 'moveToNeighboringCommit', 'setCodequalityEndpoint', - 'setSastEndpoint', 'fetchDiffFilesMeta', 'fetchDiffFilesBatch', 'fetchFileByFile', @@ -397,7 +398,6 @@ export default { 'setFileForcedOpen', 'fetchCoverageFiles', 'fetchCodequality', - 'fetchSast', 'rereadNoteHash', 'startRenderDiffsQueue', 'assignDiscussionsToDiff', @@ -516,10 +516,6 @@ export default { this.fetchCodequality(); } - if (this.endpointSast) { - this.fetchSast(); - } - if (!this.isNotesFetched) { notesEventHub.$emit('fetchNotesData'); } diff --git a/app/assets/javascripts/diffs/components/graphql/get_mr_codequality_reports.query.graphql b/app/assets/javascripts/diffs/components/graphql/get_mr_codequality_and_security_reports.query.graphql index b6920d0f6ec..0def3a63b48 100644 --- a/app/assets/javascripts/diffs/components/graphql/get_mr_codequality_reports.query.graphql +++ b/app/assets/javascripts/diffs/components/graphql/get_mr_codequality_and_security_reports.query.graphql @@ -1,9 +1,10 @@ -query getMRCodequalityReports($fullPath: ID!, $iid: String!) { +query getMRCodequalityAndSecurityReports($fullPath: ID!, $iid: String!) { project(fullPath: $fullPath) { id mergeRequest(iid: $iid) { id title + hasSecurityReports codequalityReportsComparer { report { status @@ -41,6 +42,29 @@ query getMRCodequalityReports($fullPath: ID!, $iid: String!) { } } } + sastReport: findingReportsComparer(reportType: SAST) { + status + report { + added { + uuid + title + description + state + severity + foundByPipelineIid + location { + ... on VulnerabilityLocationSast { + file + startLine + endLine + vulnerableClass + vulnerableMethod + blobPath + } + } + } + } + } } } } diff --git a/app/assets/javascripts/diffs/index.js b/app/assets/javascripts/diffs/index.js index c0b6c8159dc..d4ed48965aa 100644 --- a/app/assets/javascripts/diffs/index.js +++ b/app/assets/javascripts/diffs/index.js @@ -36,7 +36,8 @@ export default function initDiffsApp(store = notesStore) { iid: dataset.iid || '', endpointCoverage: dataset.endpointCoverage || '', endpointCodequality: dataset.endpointCodequality || '', - endpointSast: dataset.endpointSast || '', + // This is a workaround which will be solved in: https://gitlab.com/gitlab-org/gitlab/-/issues/428758 + sastReportAvailable: Boolean(dataset.endpointSast), helpPagePath: dataset.helpPagePath, currentUser: JSON.parse(dataset.currentUserData) || {}, changesEmptyStateIllustration: dataset.changesEmptyStateIllustration, @@ -86,7 +87,7 @@ export default function initDiffsApp(store = notesStore) { iid: this.iid, endpointCoverage: this.endpointCoverage, endpointCodequality: this.endpointCodequality, - endpointSast: this.endpointSast, + sastReportAvailable: this.sastReportAvailable, currentUser: this.currentUser, helpPagePath: this.helpPagePath, shouldShow: this.activeTab === 'diffs', diff --git a/app/assets/stylesheets/page_bundles/work_items.scss b/app/assets/stylesheets/page_bundles/work_items.scss index 01c6fde80da..f41a1f540e3 100644 --- a/app/assets/stylesheets/page_bundles/work_items.scss +++ b/app/assets/stylesheets/page_bundles/work_items.scss @@ -1,7 +1,7 @@ @import 'mixins_and_variables_and_functions'; $work-item-field-inset-shadow: inset 0 0 0 $gl-border-size-1 var(--gray-200, $gray-200) !important; -$work-item-overview-right-sidebar-width: 340px; +$work-item-overview-right-sidebar-width: 23rem; $work-item-sticky-header-height: 52px; .gl-token-selector-token-container { diff --git a/app/graphql/resolvers/ci/catalog/resources_resolver.rb b/app/graphql/resolvers/ci/catalog/resources_resolver.rb index 7d71ba9ca05..120efe7e01d 100644 --- a/app/graphql/resolvers/ci/catalog/resources_resolver.rb +++ b/app/graphql/resolvers/ci/catalog/resources_resolver.rb @@ -20,7 +20,9 @@ module Resolvers project = Project.find_by_full_path(project_path) apply_lookahead( - ::Ci::Catalog::Listing.new(project.root_namespace, context[:current_user]).resources(sort: sort) + ::Ci::Catalog::Listing + .new(context[:current_user]) + .resources(namespace: project.root_namespace, sort: sort) ) end diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 0d5b8755a37..8c199aefd81 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -300,7 +300,7 @@ module BlobHelper end def show_suggest_pipeline_creation_celebration? - @blob.path == Gitlab::FileDetector::PATTERNS[:gitlab_ci] && + Gitlab::FileDetector.type_of(@blob.path) == :gitlab_ci && @blob.auxiliary_viewer&.valid?(project: @project, sha: @commit.sha, user: current_user) && @project.uses_default_ci_config? && cookies[suggest_pipeline_commit_cookie_name].present? diff --git a/app/models/ci/catalog/listing.rb b/app/models/ci/catalog/listing.rb index c3b18af8c3f..17d17bc8f9f 100644 --- a/app/models/ci/catalog/listing.rb +++ b/app/models/ci/catalog/listing.rb @@ -3,42 +3,53 @@ module Ci module Catalog class Listing - # This class is the SSoT to displaying the list of resources in the - # CI/CD Catalog given a namespace as a scope. + # This class is the SSoT to displaying the list of resources in the CI/CD Catalog. # This model is not directly backed by a table and joins catalog resources # with projects to return relevant data. - def initialize(namespace, current_user) - raise ArgumentError, 'Namespace is not a root namespace' unless namespace.root? - @namespace = namespace + MIN_SEARCH_LENGTH = 3 + + def initialize(current_user) @current_user = current_user end - def resources(sort: nil) + def resources(namespace: nil, sort: nil, search: nil) + relation = all_resources(search) + relation = by_namespace(relation, namespace) + case sort.to_s - when 'name_desc' then all_resources.order_by_name_desc - when 'name_asc' then all_resources.order_by_name_asc - when 'latest_released_at_desc' then all_resources.order_by_latest_released_at_desc - when 'latest_released_at_asc' then all_resources.order_by_latest_released_at_asc + when 'name_desc' then relation.order_by_name_desc + when 'name_asc' then relation.order_by_name_asc + when 'latest_released_at_desc' then relation.order_by_latest_released_at_desc + when 'latest_released_at_asc' then relation.order_by_latest_released_at_asc else - all_resources.order_by_created_at_desc + relation.order_by_created_at_desc end end private - attr_reader :namespace, :current_user + attr_reader :current_user + + def all_resources(search) + Ci::Catalog::Resource.joins(:project).includes(:project) + .merge(find_projects(search)) + end + + def by_namespace(relation, namespace) + return relation unless namespace + raise ArgumentError, 'Namespace is not a root namespace' unless namespace.root? - def all_resources - Ci::Catalog::Resource - .joins(:project).includes(:project) - .merge(projects_in_namespace_visible_to_user) + relation.merge(Project.in_namespace(namespace.self_and_descendant_ids)) end - def projects_in_namespace_visible_to_user - Project - .in_namespace(namespace.self_and_descendant_ids) - .public_or_visible_to_user(current_user, ::Gitlab::Access::DEVELOPER) + def find_projects(search) + finder_params = { + minimum_search_length: MIN_SEARCH_LENGTH, + search: search + } + + ProjectsFinder.new(params: finder_params, current_user: current_user).execute end end end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 5bf4e846304..a7909fcedfb 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -30,8 +30,9 @@ module Ci PROJECT_ROUTE_AND_NAMESPACE_ROUTE = { project: [:project_feature, :route, { namespace: :route }] }.freeze - CONFIG_EXTENSION = '.gitlab-ci.yml' - DEFAULT_CONFIG_PATH = CONFIG_EXTENSION + + DEFAULT_CONFIG_PATH = '.gitlab-ci.yml' + CANCELABLE_STATUSES = (Ci::HasStatus::CANCELABLE_STATUSES + ['manual']).freeze paginates_per 15 diff --git a/app/models/project.rb b/app/models/project.rb index fd226d23e77..0587ff69d3a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2875,7 +2875,7 @@ class Project < ApplicationRecord end def uses_default_ci_config? - ci_config_path.blank? || ci_config_path == Gitlab::FileDetector::PATTERNS[:gitlab_ci] + ci_config_path.blank? || Gitlab::FileDetector.type_of(ci_config_path) == :gitlab_ci end def limited_protected_branches(limit) @@ -3026,7 +3026,7 @@ class Project < ApplicationRecord end def ci_config_for(sha) - repository.gitlab_ci_yml_for(sha, ci_config_path_or_default) + repository.blob_data_at(sha, ci_config_path_or_default) end def enabled_group_deploy_keys diff --git a/app/models/repository.rb b/app/models/repository.rb index e565de9c4ba..b35336d47b8 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1102,10 +1102,6 @@ class Repository blob_data_at(sha, '.gitlab/route-map.yml') end - def gitlab_ci_yml_for(sha, path = '.gitlab-ci.yml') - blob_data_at(sha, path) - end - def lfsconfig_for(sha) blob_data_at(sha, '.lfsconfig') end diff --git a/app/presenters/projects/security/configuration_presenter.rb b/app/presenters/projects/security/configuration_presenter.rb index f248652befc..a0d731f0ccf 100644 --- a/app/presenters/projects/security/configuration_presenter.rb +++ b/app/presenters/projects/security/configuration_presenter.rb @@ -55,8 +55,8 @@ module Projects def gitlab_ci_history_path return '' if project.empty_repo? - gitlab_ci = ::Gitlab::FileDetector::PATTERNS[:gitlab_ci] - ::Gitlab::Routing.url_helpers.project_blame_path(project, File.join(project.default_branch_or_main, gitlab_ci)) + ::Gitlab::Routing.url_helpers.project_blame_path( + project, File.join(project.default_branch_or_main, project.ci_config_path_or_default)) end def features diff --git a/app/services/google_cloud/generate_pipeline_service.rb b/app/services/google_cloud/generate_pipeline_service.rb index 30c358687aa..97d008db76b 100644 --- a/app/services/google_cloud/generate_pipeline_service.rb +++ b/app/services/google_cloud/generate_pipeline_service.rb @@ -67,7 +67,7 @@ module GoogleCloud end def default_branch_gitlab_ci_yml - @default_branch_gitlab_ci_yml ||= project.repository.gitlab_ci_yml_for(project.default_branch) + @default_branch_gitlab_ci_yml ||= project.ci_config_for(project.default_branch) end def pipeline_content(include_path) diff --git a/app/services/security/ci_configuration/sast_parser_service.rb b/app/services/security/ci_configuration/sast_parser_service.rb index 16a9efcefdf..f466dd0b649 100644 --- a/app/services/security/ci_configuration/sast_parser_service.rb +++ b/app/services/security/ci_configuration/sast_parser_service.rb @@ -89,17 +89,15 @@ module Security def gitlab_ci_yml_attributes @gitlab_ci_yml_attributes ||= begin - config_content = @project.repository.blob_data_at(@project.repository.root_ref_sha, ci_config_file) + config_content = @project.repository.blob_data_at( + @project.repository.root_ref_sha, @project.ci_config_path_or_default + ) return {} unless config_content build_sast_attributes(config_content) end end - def ci_config_file - '.gitlab-ci.yml' - end - def build_sast_attributes(content) options = { project: @project, user: current_user, sha: @project.repository.commit.sha } yaml_result = Gitlab::Ci::YamlProcessor.new(content, options).execute |