summaryrefslogtreecommitdiff
path: root/app/services/security/ci_configuration/sast_create_service.rb
blob: 643cb7f89dcdad213746d466f1a26dfb5a1e271e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

module Security
  module CiConfiguration
    class SastCreateService < ::Security::CiConfiguration::BaseCreateService
      attr_reader :params

      def initialize(project, current_user, params, commit_on_default: false)
        super(project, current_user)
        @params = params

        @commit_on_default = commit_on_default
        @branch_name = project.default_branch if @commit_on_default
      end

      private

      def remove_branch_on_exception
        super unless @commit_on_default
      end

      def action
        Security::CiConfiguration::SastBuildAction.new(project.auto_devops_enabled?, params, existing_gitlab_ci_content, project.ci_config_path).generate
      end

      def next_branch
        'set-sast-config'
      end

      def message
        _('Configure SAST in `.gitlab-ci.yml`, creating this file if it does not already exist')
      end

      def description
        _('Configure SAST in `.gitlab-ci.yml` using the GitLab managed template. You can [add variable overrides](https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings) to customize SAST settings.')
      end

      def name
        'SAST'
      end
    end
  end
end