summaryrefslogtreecommitdiff
path: root/app/presenters/projects/security/configuration_presenter.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-16 09:13:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-16 09:13:21 +0000
commit2c90b9b579fbfe3db191a032d2cb176761605a02 (patch)
treed9819280a1ec64ff82c31ce6081e00745a9648b4 /app/presenters/projects/security/configuration_presenter.rb
parentccca6cec346d169fa2521c390760af9bd885ea77 (diff)
downloadgitlab-ce-2c90b9b579fbfe3db191a032d2cb176761605a02.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/presenters/projects/security/configuration_presenter.rb')
-rw-r--r--app/presenters/projects/security/configuration_presenter.rb100
1 files changed, 0 insertions, 100 deletions
diff --git a/app/presenters/projects/security/configuration_presenter.rb b/app/presenters/projects/security/configuration_presenter.rb
deleted file mode 100644
index 8f8f5bea0b6..00000000000
--- a/app/presenters/projects/security/configuration_presenter.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-# frozen_string_literal: true
-
-module Projects
- module Security
- class ConfigurationPresenter < Gitlab::View::Presenter::Delegated
- include AutoDevopsHelper
- include ::Security::LatestPipelineInformation
-
- delegator_override_with Gitlab::Utils::StrongMemoize
-
- presents ::Project, as: :project
-
- def to_h
- {
- auto_devops_enabled: auto_devops_source?,
- auto_devops_help_page_path: help_page_path('topics/autodevops/index'),
- auto_devops_path: auto_devops_settings_path(project),
- can_enable_auto_devops: can_enable_auto_devops?,
- features: features,
- help_page_path: help_page_path('user/application_security/index'),
- latest_pipeline_path: latest_pipeline_path,
- # TODO: gitlab_ci_present will incorrectly report `false` if the CI/CD configuration file name
- # has been customized and a file with the given custom name exists in the repo. This edge case
- # will be addressed in https://gitlab.com/gitlab-org/gitlab/-/issues/342465
- gitlab_ci_present: project.repository.gitlab_ci_yml.present?,
- gitlab_ci_history_path: gitlab_ci_history_path,
- auto_fix_enabled: autofix_enabled,
- can_toggle_auto_fix_settings: can_toggle_autofix,
- auto_fix_user_path: auto_fix_user_path
- }
- end
-
- def to_html_data_attribute
- data = to_h
- data[:features] = data[:features].to_json
- data[:auto_fix_enabled] = data[:auto_fix_enabled].to_json
-
- data
- end
-
- private
-
- def autofix_enabled; end
-
- def auto_fix_user_path; end
-
- def can_enable_auto_devops?
- feature_available?(:builds, current_user) &&
- can?(current_user, :admin_project, self) &&
- !archived?
- end
-
- def can_toggle_autofix; end
-
- 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))
- end
-
- def features
- scans = scan_types.map do |scan_type|
- scan(scan_type, configured: scanner_enabled?(scan_type))
- end
-
- # These scans are "fake" (non job) entries. Add them manually.
- scans << scan(:corpus_management, configured: true)
- scans << scan(:dast_profiles, configured: true)
- end
-
- def latest_pipeline_path
- return help_page_path('ci/pipelines') unless latest_default_branch_pipeline
-
- project_pipeline_path(self, latest_default_branch_pipeline)
- end
-
- def scan(type, configured: false)
- scan = ::Gitlab::Security::ScanConfiguration.new(project: project, type: type, configured: configured)
-
- {
- type: scan.type,
- configured: scan.configured?,
- configuration_path: scan.configuration_path,
- available: scan.available?
- }
- end
-
- def scan_types
- ::Security::SecurityJobsFinder.allowed_job_types + ::Security::LicenseComplianceJobsFinder.allowed_job_types
- end
-
- def project_settings
- project.security_setting
- end
- end
- end
-end
-
-Projects::Security::ConfigurationPresenter.prepend_mod_with('Projects::Security::ConfigurationPresenter')